Exemplo n.º 1
0
        public JsonResult Edit(HotelRoomImageManageModel model)
        {
            if (ModelState.IsValid)
            {
                return Json(_hotelRoomImageServices.SaveHotelRoomImage(model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save HotelRoom image
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveHotelRoomImage(HotelRoomImageManageModel model)
        {
            ResponseModel response;
            var hotelRoomImage = GetById(model.Id);
            if (hotelRoomImage != null)
            {
                hotelRoomImage.ImageUrl = model.ImageUrl;
                hotelRoomImage.Description = model.Description;
                hotelRoomImage.HotelRoomTypeId = model.HotelRoomTypeId;

                response = Update(hotelRoomImage);
                return response.SetMessage(response.Success ?
                    _localizedResourceServices.T("AdminModule:::HotelRoomImages:::Messages:::UpdateSuccessfully:::Update room image successfully.")
                    : _localizedResourceServices.T("AdminModule:::HotelRoomImages:::Messages:::UpdateFailure:::Update room image failed. Please try again later."));
            }
            Mapper.CreateMap<HotelRoomImageManageModel, HotelRoomImage>();
            hotelRoomImage = Mapper.Map<HotelRoomImageManageModel, HotelRoomImage>(model);
            hotelRoomImage.RecordOrder = Fetch(i => i.HotelRoomTypeId == model.HotelRoomTypeId).Any() ? Fetch(i => i.HotelRoomTypeId == model.HotelRoomTypeId).Max(i => i.RecordOrder) + 1 : 0;
            response = Insert(hotelRoomImage);
            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::HotelRoomImages:::Messages:::CreateSuccessfully:::Create room image successfully.")
                : _localizedResourceServices.T("AdminModule:::HotelRoomImages:::Messages:::CreateFailure:::Create room image failed. Please try again later."));
        }