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); } }
public override void DoOperation() { try { //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 ADD long checkGuid = 0; this.captain = new Captains { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CAPTAIN_NAME = this.request.CAPTAIN_NAME, CAPTAIN_MIDDLE_NAME = this.request.CAPTAIN_MIDDLE_NAME, CAPTAIN_SURNAME = this.request.CAPTAIN_SURNAME, BOAT_ID = this.request.BOAT_ID, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, CAPTAIN_INFO = this.request.CAPTAIN_INFO }; //Add Data to Database checkGuid = Captains.Insert(this.captain); //Connect captain to related Boat Boats boat = new Boats(); boat = Boats.SelectByBoatId(this.captain.BOAT_ID); boat.CAPTAIN_ID = checkGuid; Boats.Update(boat); this.response = new ResponseCaptain { CAPTAIN_ID = checkGuid, CAPTAIN_NAME = this.request.CAPTAIN_NAME, CAPTAIN_MIDDLE_NAME = this.request.CAPTAIN_MIDDLE_NAME, CAPTAIN_SURNAME = this.request.CAPTAIN_SURNAME, BOAT_ID = this.request.BOAT_ID, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, CAPTAIN_INFO = this.request.CAPTAIN_INFO, 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.UPDATE: #region UPDATE this.captain = new Captains { UPDATE_USER = this.request.UPDATE_USER, CAPTAIN_NAME = this.request.CAPTAIN_NAME, CAPTAIN_MIDDLE_NAME = this.request.CAPTAIN_MIDDLE_NAME, CAPTAIN_SURNAME = this.request.CAPTAIN_SURNAME, BOAT_ID = this.request.BOAT_ID, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, CAPTAIN_INFO = this.request.CAPTAIN_INFO }; //Modify Data to Database Captains.Update(this.captain); this.response = new ResponseCaptain { CAPTAIN_NAME = this.request.CAPTAIN_NAME, CAPTAIN_MIDDLE_NAME = this.request.CAPTAIN_MIDDLE_NAME, CAPTAIN_SURNAME = this.request.CAPTAIN_SURNAME, BOAT_ID = this.request.BOAT_ID, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, CAPTAIN_INFO = this.request.CAPTAIN_INFO, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.GET: #region GET //Get Data this.captain = Captains.SelectByBoatId(this.request.BOAT_ID); this.response = new ResponseCaptain { CAPTAIN_NAME = this.captain.CAPTAIN_NAME, CAPTAIN_MIDDLE_NAME = this.captain.CAPTAIN_MIDDLE_NAME, CAPTAIN_SURNAME = this.captain.CAPTAIN_SURNAME, BOAT_ID = this.captain.BOAT_ID, IDENTIFICATION_ID = this.captain.IDENTIFICATION_ID, EMAIL = this.captain.EMAIL, PHONE_NUMBER = this.captain.PHONE_NUMBER, CAPTAIN_INFO = this.captain.CAPTAIN_INFO, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; #endregion break; case (int)OperationType.OperationTypes.DELETE: #region DELETE this.captain = Captains.SelectByBoatId(this.request.BOAT_ID); Captains.Delete(this.captain); this.response = new ResponseCaptain { CAPTAIN_NAME = "", CAPTAIN_MIDDLE_NAME = "", CAPTAIN_SURNAME = "", BOAT_ID = this.captain.BOAT_ID, IDENTIFICATION_ID = 0, EMAIL = "", PHONE_NUMBER = "", CAPTAIN_INFO = "", header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; //DisConnect captain to related Boat Boats boats = new Boats(); boats = Boats.SelectByBoatId(this.captain.BOAT_ID); boats.CAPTAIN_ID = 0; Boats.Update(boats); #endregion break; default: break; } } catch (Exception ex) { string operationError = "HATA:[" + "CaptainId:" + this.request.CAPTAIN_ID + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]"; log.InfoFormat(operationError, ex); throw new Exception(ex.Message, ex.InnerException); } }