public JsonResult Manage(HotelBookingModel model, GridManagingModel manageModel) { if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del) { return Json(_hotelBookingServices.ManageHotelBooking(manageModel.Operation, model)); } return Json(new ResponseModel { Success = false, Message = GetFirstValidationResults(ModelState).Message }); }
/// <summary> /// Manage Site HotelBooking /// </summary> /// <param name="operation">the operation</param> /// <param name="model">the HotelBooking model</param> /// <returns></returns> public ResponseModel ManageHotelBooking(GridOperationEnums operation, HotelBookingModel model) { ResponseModel response; Mapper.CreateMap<HotelBookingModel, HotelBooking>(); HotelBooking hotelBooking; switch (operation) { case GridOperationEnums.Edit: hotelBooking = GetById(model.Id); hotelBooking.TotalMoney = model.TotalMoney; hotelBooking.Note = model.Note; hotelBooking.Status = model.Status; response = Update(hotelBooking); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::UpdateSuccessfully:::Update booking successfully.") : _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::UpdateFailure:::Update booking failed. Please try again later.")); case GridOperationEnums.Add: hotelBooking = Mapper.Map<HotelBookingModel, HotelBooking>(model); hotelBooking.Status = model.Status; response = Insert(hotelBooking); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::CreateSuccessfully:::Create booking successfully.") : _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::CreateFailure:::Insert booking failed. Please try again later.")); case GridOperationEnums.Del: response = Delete(model.Id); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::DeleteSuccessfully:::Delete booking successfully.") : _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::DeleteFailure:::Delete booking failed. Please try again later.")); } return new ResponseModel { Success = false, Message = _localizedResourceServices.T("AdminModule:::HotelBookings:::Messages:::ObjectNotFounded:::Booking is not founded.") }; }