public JsonResult Manage(HotelServiceModel model, GridManagingModel manageModel) { if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del) { return(Json(_hotelServiceServices.ManageHotelService(manageModel.Operation, model))); } return(Json(new ResponseModel { Success = false, Message = GetFirstValidationResults(ModelState).Message })); }
/// <summary> /// Manage Site HotelService /// </summary> /// <param name="operation">the operation</param> /// <param name="model">the HotelService model</param> /// <returns></returns> public ResponseModel ManageHotelService(GridOperationEnums operation, HotelServiceModel model) { ResponseModel response; Mapper.CreateMap <HotelServiceModel, HotelService>(); HotelService hotelService; switch (operation) { case GridOperationEnums.Edit: hotelService = GetById(model.Id); hotelService.Name = model.Name; hotelService.ServiceIcon = model.ServiceIcon; hotelService.RecordOrder = model.RecordOrder; response = Update(hotelService); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::UpdateSuccessfully:::Update service successfully.") : _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::UpdateFailure:::Update service failed. Please try again later."))); case GridOperationEnums.Add: hotelService = Mapper.Map <HotelServiceModel, HotelService>(model); response = Insert(hotelService); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::CreateSuccessfully:::Create service successfully.") : _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::CreateFailure:::Insert service failed. Please try again later."))); case GridOperationEnums.Del: response = Delete(model.Id); return(response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::DeleteSuccessfully:::Delete service successfully.") : _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::DeleteFailure:::Delete service failed. Please try again later."))); } return(new ResponseModel { Success = false, Message = _localizedResourceServices.T("AdminModule:::HotelServices:::Messages:::ObjectNotFounded:::Service is not founded.") }); }