Exemplo n.º 1
0
        public override void DoOperation()
        {
            //Validate Reques Header / Constants
            this.baseResponseMessage = ValidateInput();
            if (!this.baseResponseMessage.header.IsSuccess)
            {
                throw new Exception(this.baseResponseMessage.header.ResponseMessage);
            }


            //Operation
            switch (this.request.Header.OperationTypes)
            {
            case (int)OperationType.OperationTypes.ADD:
                #region Reserve
                this.request.RESERVATION_ID = CommonServices.AddReservation(this.request, ref checkValue);

                response = new ResponseReservation
                {
                    BOAT_ID              = this.request.BOAT_ID,
                    CUSTOMER_NUMBER      = this.request.CUSTOMER_NUMBER,
                    PRICE                = this.request.PRICE,
                    PAYMENT_ID           = this.request.PAYMENT_ID,
                    PAYMENT_TYPE         = this.request.PAYMENT_TYPE,
                    RESERVATION_DATE     = this.request.RESERVATION_DATE,
                    RESERVATION_END_DATE = this.request.RESERVATION_END_DATE,
                    TOUR_TYPE            = this.request.TOUR_TYPE,
                    RESERVATION_ID       = this.request.RESERVATION_ID,
                    CAPACITY             = this.request.CAPACITY,
                    CONFIRM              = this.request.CONFIRM,
                    header               = new ResponseHeader
                    {
                        IsSuccess       = checkValue == false ? false : true,
                        ResponseCode    = checkValue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                        ResponseMessage = checkValue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                    }
                };
                #endregion
                break;

            case (int)OperationType.OperationTypes.GET:
                if (this.request.BOAT_ID != 0)
                {
                    //Get by BoatId
                    listReservationResponse = reservationService.SelectByBoatId(this.request.BOAT_ID);
                }
                else if (this.request.CUSTOMER_NUMBER != 0)
                {
                    //Get by CustomerNumber
                    listReservationResponse = reservationService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER);
                }
                else if (!String.IsNullOrEmpty(this.request.PAYMENT_ID))
                {
                    //Get by PaymentId
                    listReservationResponse = reservationService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER);
                }
                break;

            case (int)OperationType.OperationTypes.UPDATE:
                #region Modify Reserve
                CommonServices.ModifyReservation(this.request, ref checkValue);

                response = new ResponseReservation
                {
                    BOAT_ID              = this.request.BOAT_ID,
                    CUSTOMER_NUMBER      = this.request.CUSTOMER_NUMBER,
                    PRICE                = this.request.PRICE,
                    PAYMENT_ID           = this.request.PAYMENT_ID,
                    PAYMENT_TYPE         = this.request.PAYMENT_TYPE,
                    RESERVATION_DATE     = this.request.RESERVATION_DATE,
                    RESERVATION_END_DATE = this.request.RESERVATION_END_DATE,
                    TOUR_TYPE            = this.request.TOUR_TYPE,
                    RESERVATION_ID       = this.request.RESERVATION_ID,
                    CAPACITY             = this.request.CAPACITY,
                    CONFIRM              = this.request.CONFIRM,
                    header               = new ResponseHeader
                    {
                        IsSuccess       = checkValue == false ? false : true,
                        ResponseCode    = checkValue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                        ResponseMessage = checkValue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                    }
                };
                #endregion
                break;

            case (int)OperationType.OperationTypes.DELETE:
                #region Modify Cancel of Reservation
                CommonServices.ModifyReservation(this.request, ref checkValue);

                response = new ResponseReservation
                {
                    BOAT_ID              = this.request.BOAT_ID,
                    CUSTOMER_NUMBER      = this.request.CUSTOMER_NUMBER,
                    PRICE                = this.request.PRICE,
                    PAYMENT_ID           = this.request.PAYMENT_ID,
                    PAYMENT_TYPE         = this.request.PAYMENT_TYPE,
                    RESERVATION_DATE     = this.request.RESERVATION_DATE,
                    RESERVATION_END_DATE = this.request.RESERVATION_END_DATE,
                    TOUR_TYPE            = this.request.TOUR_TYPE,
                    RESERVATION_ID       = this.request.RESERVATION_ID,
                    CAPACITY             = this.request.CAPACITY,
                    CONFIRM              = this.request.CONFIRM,
                    header               = new ResponseHeader
                    {
                        IsSuccess       = checkValue == false ? false : true,
                        ResponseCode    = checkValue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                        ResponseMessage = checkValue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                    }
                };
                #endregion
                break;

            default:
                break;
            }
        }