コード例 #1
0
 public ResponseModel Delete(HotelRoomType hotelRoomType)
 {
     return _hotelRoomTypeRepository.Delete(hotelRoomType);
 }
コード例 #2
0
        /// <summary>
        /// Save HotelRoomType manage model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveHotelRoomTypeManageModel(HotelRoomTypeManageModel model)
        {
            ResponseModel response;
            var hotelRoomType = GetById(model.Id);

            #region Edit HotelRoomType
            if (hotelRoomType != null)
            {
                hotelRoomType.Name = model.Name;
                hotelRoomType.Description = model.Description;
                hotelRoomType.Price = model.Price;
                hotelRoomType.RecordOrder = model.RecordOrder;

                var currentServices = hotelRoomType.HotelRoomServices.Select(rs => rs.ServiceId).ToList();
                foreach (var id in currentServices)
                {
                    if (!model.HotelRoomTypeServiceIds.Contains(id))
                    {
                        _hotelRoomServiceRepository.Delete(id);
                    }
                }
                foreach (var serviceId in model.HotelRoomTypeServiceIds)
                {
                    if (currentServices.All(n => n != serviceId))
                    {
                        var hotelRoomTypeHotelRoomTypeCategory = new HotelRoomService
                        {
                            RoomTypeId = hotelRoomType.Id,
                            ServiceId = serviceId
                        };
                        _hotelRoomServiceRepository.Insert(hotelRoomTypeHotelRoomTypeCategory);
                    }
                }

                //Get page record order
                response = Update(hotelRoomType);
                return response.SetMessage(response.Success ?
                    _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::UpdateSuccessfully:::Update HotelRoomType successfully.")
                    : _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::UpdateFailure:::Update HotelRoomType failed. Please try again later."));
            }
            #endregion

            hotelRoomType = new HotelRoomType
            {
                Name = model.Name,
                Description = model.Description,
                Price = model.Price,
            };

            response = Insert(hotelRoomType);
            foreach (var serviceId in model.HotelRoomTypeServiceIds)
            {
                var hotelRoomTypeHotelRoomTypeCategory = new HotelRoomService
                {
                    RoomTypeId = hotelRoomType.Id,
                    ServiceId = serviceId
                };
                _hotelRoomServiceRepository.Insert(hotelRoomTypeHotelRoomTypeCategory);
            }
            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::CreateSuccessfully:::Create HotelRoomType successfully.")
                : _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::CreateFailure:::Create HotelRoomType failed. Please try again later."));
        }
コード例 #3
0
 public ResponseModel Update(HotelRoomType hotelRoomType)
 {
     return _hotelRoomTypeRepository.Update(hotelRoomType);
 }
コード例 #4
0
 public ResponseModel Insert(HotelRoomType hotelRoomType)
 {
     return _hotelRoomTypeRepository.Insert(hotelRoomType);
 }