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.favorite = new Favorites { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, BOAT_ID = this.request.BOAT_ID }; checkGuid = Favorites.Insert(this.favorite); this.response = new ResponseFavorites { BOAT_ID = this.request.BOAT_ID, CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER, 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 listfavorites = Favorites.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER); //Take all favorites for CustomerNumber foreach (var item in listfavorites) { this.response = new ResponseFavorites { CUSTOMER_NUMBER = item.CUSTOMER_NUMBER, BOAT_ID = item.BOAT_ID, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; responseAllFavorite.Add(this.response); } //Take All Boat Info for Favorites this.listboat = Boats.SelectAllBoat(); this.listregion = Region.SelectAllRegion(); foreach (var item in responseAllFavorite) { this.boat = this.listboat.Where(s => s.BOAT_ID == item.BOAT_ID).FirstOrDefault(); this.responseBoats = new ResponseBoats { 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, REGION_ID = this.boat.REGION_ID, ROTA_INFO = this.boat.ROTA_INFO, REGION_NAME = Enum.GetName(typeof(Enums.Region), this.boat.REGION_ID), header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; reponseAllBoats.Add(this.responseBoats); } #endregion break; case (int)OperationType.OperationTypes.DELETE: #region DELETE if (!this.request.IsDeleteByCustomerNumber) { this.favorite = new Favorites { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, BOAT_ID = this.request.BOAT_ID }; if (Favorites.Delete(this.favorite)) { this.response = new ResponseFavorites { CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER, BOAT_ID = this.favorite.BOAT_ID, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; } } else { //Delete all Favorites Boats for customer if (Favorites.DeleteAllforCustomer(this.favorite.CUSTOMER_NUMBER)) { this.response = new ResponseFavorites { CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER, BOAT_ID = this.favorite.BOAT_ID, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; } } #endregion break; default: break; } } catch (Exception ex) { string operationError = "HATA:[" + "CustomerNumber:" + this.request.CUSTOMER_NUMBER + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]"; log.InfoFormat(operationError, ex); throw new Exception(ex.Message, ex.InnerException); } }