server/src/Entity/subscription.js
/**
    * Method to create the subscription.
    * @param serviceDetails: the array containing the service ids and the count.
    * @param empId: The employee taking the action.
    * @returns {Promise<Object>}: the id of the subscription created, else -1.
    */
Method to create the subscription.
@param serviceDetails: the array containing the service ids and the count.
@param empId: The employee taking the action.
@returns {Promise}: the id of the subscription created, else -1.
Method to create the subscription . @param serviceDetails : the array containing the service ids and the count . @param empId : The employee taking the action . @returns { Promise } : the id of the subscription created else - 1 .
createSubscription(serviceDetails, empId) {
      return new Promise((resolve, reject) => {
         let serviceIds = [];
         let serviceCount = [];
         serviceDetails.forEach(oneService => {
            serviceIds.push(Object.keys(oneService)[0]);
            serviceCount.push(oneService[Object.keys(oneService)[0]]);
         });
         database.runSp(constants.SP_SUBSCRIPTION_REGISTRATION, [empId, this._subscriptionName,
            this._subscriptionAmount, serviceIds.join(","), serviceCount.join(","), this._startDate, this._endDate])
            .then(_resultSet => {
               const result = _resultSet[0][0];
               if (validators.validateUndefined(result)) {
                  resolve(result);
               } else {
                  resolve({"id": -1});
               }
            }).catch(err => {
            printer.printError(err);
            reject(err);
         });
      });
   }
createSubscription ( serviceDetails , empId ) { return new Promise ( ( resolve , reject ) => { let serviceIds = [ ] ; let serviceCount = [ ] ; serviceDetails . forEach ( oneService => { serviceIds . push ( Object . keys ( oneService ) [ 0 ] ) ; serviceCount . push ( oneService [ Object . keys ( oneService ) [ 0 ] ] ) ; } ) ; database . runSp ( constants . SP_SUBSCRIPTION_REGISTRATION , [ empId , this . _subscriptionName , this . _subscriptionAmount , serviceIds . join ( "," ) , serviceCount . join ( "," ) , this . _startDate , this . _endDate ] ) . then ( _resultSet => { const result = _resultSet [ 0 ] [ 0 ] ; if ( validators . validateUndefined ( result ) ) { resolve ( result ) ; } else { resolve ( { "id" : - 1 } ) ; } } ) . catch ( err => { printer . printError ( err ) ; reject ( err ) ; } ) ; } ) ; }
Method to create the subscription.
Method to create the subscription .