コード例 #1
0
        public ResponseModel SortImages(RoomTypeImageSortingModel model)
        {
            var roomType = GetById(model.RoomTypeId);

            if (roomType != null)
            {
                var images     = roomType.HotelRoomImages.OrderBy(i => model.Ids.ToList().IndexOf(i.Id)).ToList();
                var dictionary = images.OrderBy(i => i.RecordOrder).Select(i => new { i.Id, i.RecordOrder }).ToList();
                var index      = 0;
                foreach (var image in images)
                {
                    if (image.Id != dictionary[index].Id)
                    {
                        image.RecordOrder = dictionary[index].RecordOrder;
                        _hotelRoomImageRepository.Update(image);
                    }
                    index++;
                }
                return(new ResponseModel
                {
                    Success = true,
                    Message = _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::SortSuccessfully:::Sort successfully.")
                });
            }
            return(new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::HotelRoomTypes:::Messages:::ObjectNotFounded:::Room is not founded.")
            });
        }
コード例 #2
0
 public ResponseModel Update(HotelRoomImage hotelRoomImage)
 {
     return(_hotelRoomImageRepository.Update(hotelRoomImage));
 }