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

                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region Add
                    long checkGuid = 0;
                    this.boat = new Boats
                    {
                        INSERT_USER   = this.request.INSERT_USER,
                        UPDATE_USER   = this.request.UPDATE_USER,
                        BOAT_INFO     = this.request.BOAT_INFO,
                        BOAT_NAME     = this.request.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE
                    };

                    checkGuid = Boats.Insert(this.boat);

                    this.response = new ResponseBoats
                    {
                        INSERT_USER   = this.boat.INSERT_USER,
                        UPDATE_USER   = this.boat.UPDATE_USER,
                        BOAT_ID       = this.boat.BOAT_ID,
                        BOAT_INFO     = this.boat.BOAT_INFO,
                        BOAT_NAME     = this.boat.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        REGION_NAME   = CommonServices.GetRegionName(this.request.REGION_ID),
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE,
                        header        = new ResponseHeader
                        {
                            IsSuccess       = checkGuid == 0 ? false : true,
                            ResponseCode    = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region GET
                    //Bölgesel Arama
                    if (this.request.REGION_ID != 0)
                    {
                        this.listboat = Boats.SelectByRegionId(this.request.REGION_ID);
                        if (listboat != null && listboat.Count > 0)
                        {
                            foreach (var item in listboat)
                            {
                                this.response = new ResponseBoats
                                {
                                    INSERT_USER = item.INSERT_USER,
                                    UPDATE_USER = item.UPDATE_USER,
                                    BOAT_ID     = item.BOAT_ID,
                                    BOAT_INFO   = item.BOAT_INFO,
                                    BOAT_NAME   = item.BOAT_NAME,
                                    CAPTAIN_ID  = item.CAPTAIN_ID,
                                    FLAG        = item.FLAG,
                                    QUANTITY    = item.QUANTITY,
                                    ROTA_INFO   = item.ROTA_INFO,
                                    REGION_ID   = item.REGION_ID,
                                    REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                                    header      = new ResponseHeader
                                    {
                                        IsSuccess       = true,
                                        ResponseCode    = CommonDefinitions.SUCCESS,
                                        ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                                    }
                                };
                                reponseAllBoats.Add(this.response);
                            }
                            this.response.AllBoats = reponseAllBoats;
                        }
                    }
                    else
                    {
                        //Tekli Arama
                        this.boat = Boats.SelectByBoatId(this.request.BOAT_ID);

                        this.response = new ResponseBoats
                        {
                            INSERT_USER = this.boat.INSERT_USER,
                            UPDATE_USER = this.boat.UPDATE_USER,
                            BOAT_ID     = this.boat.BOAT_ID,
                            BOAT_INFO   = this.boat.BOAT_INFO,
                            BOAT_NAME   = this.boat.BOAT_NAME,
                            CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                            FLAG        = this.boat.FLAG,
                            QUANTITY    = this.boat.QUANTITY,
                            ROTA_INFO   = this.boat.ROTA_INFO,
                            REGION_ID   = this.boat.REGION_ID,
                            REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                            header      = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region  Update
                    this.boat = new Boats
                    {
                        BOAT_ID       = this.request.BOAT_ID,
                        INSERT_USER   = this.request.INSERT_USER,
                        UPDATE_USER   = this.request.UPDATE_USER,
                        BOAT_INFO     = this.request.BOAT_INFO,
                        BOAT_NAME     = this.request.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE
                    };

                    Boats.Update(this.boat);

                    this.response = new ResponseBoats
                    {
                        INSERT_USER = this.boat.INSERT_USER,
                        UPDATE_USER = this.boat.UPDATE_USER,
                        BOAT_ID     = this.boat.BOAT_ID,
                        BOAT_INFO   = this.boat.BOAT_INFO,
                        BOAT_NAME   = this.boat.BOAT_NAME,
                        CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                        FLAG        = this.boat.FLAG,
                        QUANTITY    = this.boat.QUANTITY,
                        ROTA_INFO   = this.boat.ROTA_INFO,
                        REGION_ID   = this.boat.REGION_ID,
                        REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                        header      = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region DELETE
                    this.boat = new Boats
                    {
                        INSERT_USER = this.request.INSERT_USER,
                        UPDATE_USER = this.request.UPDATE_USER,
                        BOAT_INFO   = this.request.BOAT_INFO,
                        BOAT_NAME   = this.request.BOAT_NAME,
                        CAPTAIN_ID  = this.request.CAPTAIN_ID,
                        FLAG        = this.request.FLAG,
                        QUANTITY    = this.request.QUANTITY,
                        ROTA_INFO   = this.request.ROTA_INFO,
                        REGION_ID   = this.request.REGION_ID
                    };

                    Boats.Delete(this.boat);
                    this.response = new ResponseBoats
                    {
                        INSERT_USER = this.boat.INSERT_USER,
                        UPDATE_USER = this.boat.UPDATE_USER,
                        BOAT_ID     = this.boat.BOAT_ID,
                        BOAT_INFO   = this.boat.BOAT_INFO,
                        BOAT_NAME   = this.boat.BOAT_NAME,
                        CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                        FLAG        = this.boat.FLAG,
                        QUANTITY    = this.boat.QUANTITY,
                        ROTA_INFO   = this.boat.ROTA_INFO,
                        REGION_ID   = this.boat.REGION_ID,
                        REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                        header      = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                string operationError = "HATA:[" + "BoatId:" + this.request.BOAT_ID + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]";
                log.InfoFormat(operationError, ex);
                throw new Exception(ex.Message, ex.InnerException);
            }
        }