예제 #1
0
 public bool SaveRoomInfo(RoomModel roomModel)
 {
     var room = RoomModelConvertor.ConvertToEFModel(roomModel);
     if (room != null)
     {
         _unitOfWork.RoomRepository.Insert(room);
         return _unitOfWork.Commit() > 0;
     }
     return false;
 }
예제 #2
0
 /// <summary>
 /// 根据id获得房间的详细信息
 /// </summary>
 /// <param name="roomId"></param>
 /// <returns></returns>
 public RoomModel GetPreviewRoomInfo(int roomId)
 {
     var room = _unitOfWork.RoomRepository.Query().FirstOrDefault(s => s.Id == roomId);
     RoomModel roomPreview = new RoomModel();
     if (room != null)
     {
         roomPreview = RoomModelConvertor.ConvertToViewModel(room);
     }
     return roomPreview;
 }
예제 #3
0
        public static Room ConvertToEFModel(RoomModel room)
        {
            Room model = new Room();
            if (room != null)
            {

                model.RoomImageInfo = room.RoomImageInfo.Select(b => new RoomImageInfo
                {
                    ImgUrl = b.ImgUrl,
                }).ToList();
                model.RoomArea = room.RoomArea;
                model.Smoke = room.Smoke;
                model.AirportTransfer = room.AirportTransfer;
                model.Bathtub = room.Bathtub;
                model.BedType1 = room.BedType1;
                model.BedType2 = room.BedType2;
                model.BedType3 = room.BedType3;
                model.BedType4 = room.BedType4;
                model.Child = room.Child;
                model.Computer = room.Computer;
                model.Elevator = room.Elevator;
                model.Fridge = room.Fridge;
                model.Guide = room.Guide;
                model.HotWater = room.HotWater;
                model.Intercom = room.Intercom;
                model.IsBasement = room.IsBasement;
                model.LeftLuggage = room.LeftLuggage;
                model.Older = room.Older;
                model.Police = room.Police;
                model.PrivateBathroom = room.PrivateBathroom;
                model.PublicBathroom = room.PublicBathroom;
                model.RoomBalcony = room.RoomBalcony;
                model.RoomCity = room.RoomCity;
                model.RoomCount = room.RoomCount;
                model.RoomDetailedAddress = room.RoomDetailedAddress;
                model.RoomKitchen = room.RoomKitchen;
                model.RoomLang = room.RoomLang;
                model.RoomLong = room.RoomLong;
                model.Shower = room.Shower;
                model.RoomNumber = room.RoomNumber;
                model.RoomShi = room.RoomShi;
                model.RoomSpace = room.RoomSpace;
                model.RoomTing = room.RoomTing;
                model.RoomType = room.RoomType;
                model.Slippers = room.Slippers;
                model.Toiletries = room.Toiletries;
                model.Towel = room.Towel;
                model.WashingMechine = room.WashingMechine;
                model.Water = room.Water;
                model.RoomName = room.RoomName;
                model.RoomNameEN = room.RoomNameEN;
                model.RoomNameTW = room.RoomNameTW;
            }
            return model;
        }
예제 #4
0
 public ActionResult EditStep1(RoomModel model)
 {
     Session["rental.room"] = model;
     return RedirectToAction("EditStep2");
 }
예제 #5
0
 public ActionResult CreateStep1(RoomModel roomModel)
 {
     Session["rental.room"] = roomModel;
     return RedirectToAction("CreateStep2");
 }
예제 #6
0
        public static RoomModel ConvertToViewModel(Room room)
        {
            string hostName = ConfigurationSettings.AppSettings["HOSTNAME"].ToString();
            RoomModel model = new RoomModel();
            if (room != null)
            {
                model.RoomImageInfo = room.RoomImageInfo.Select(b => new RoomImageInfoModel
               {
                   ImgUrl = hostName + "Upload/RoomImg/" + b.ImgUrl,
                   ImgUrlThumb = hostName + "Upload/RoomImg/Thumb/" + b.ImgUrl,
                   OriginImg = b.ImgUrl

               }).ToList();
                model.RoomArea = room.RoomArea;
                model.RoomTypeName = GetRoomType(room.RoomType);
                model.RoomBaseName = GetRoomBaseType(room.IsBasement);
                model.Smoke = room.Smoke.GetValueOrDefault();
                model.AirportTransfer = room.AirportTransfer;
                model.Bathtub = room.Bathtub;
                model.BedType1 = room.BedType1;
                model.BedType2 = room.BedType2;
                model.BedType3 = room.BedType3;
                model.BedType4 = room.BedType4;
                model.Child = room.Child;
                model.Computer = room.Computer;
                model.Elevator = room.Elevator;
                model.Fridge = room.Fridge;
                model.Guide = room.Guide;
                model.HotWater = room.HotWater;
                model.Intercom = room.Intercom;
                model.IsBasement = room.IsBasement;
                model.LeftLuggage = room.LeftLuggage;
                model.Older = room.Older;
                model.Police = room.Police;
                model.PrivateBathroom = room.PrivateBathroom;
                model.PublicBathroom = room.PublicBathroom;
                model.RoomBalcony = room.RoomBalcony;
                model.RoomCity = room.RoomCity;
                model.RoomCount = room.RoomCount;
                model.RoomDetailedAddress = room.RoomDetailedAddress;
                model.RoomKitchen = room.RoomKitchen;
                model.RoomLang = room.RoomLang;
                model.RoomLong = room.RoomLong;
                model.Shower = room.Shower;
                model.RoomNumber = room.RoomNumber;
                model.RoomShi = room.RoomShi;
                model.RoomSpace = room.RoomSpace;
                model.RoomTing = room.RoomTing;
                model.RoomType = room.RoomType;
                model.Slippers = room.Slippers;
                model.Toiletries = room.Toiletries;
                model.Towel = room.Towel;
                model.WashingMechine = room.WashingMechine;
                model.Water = room.Water;
                model.RoomName = room.RoomName;
                model.RoomNameEN = room.RoomNameEN;
                model.RoomNameTW = room.RoomNameTW;
            }
            return model;
        }
예제 #7
0
        public bool UpdateRoomInfo(RoomModel room)
        {
            int id = room.Id;
            if (id != 0)
            {
                var model = _unitOfWork.RoomRepository.Query().FirstOrDefault(s => s.Id == id);

                if (room.RoomImageInfo != null && room.RoomImageInfo.Count > 0)
                {
                    room.RoomImageInfo.ToList().Clear();
                }
                foreach (var item in room.RoomImageInfo)
                {
                    model.RoomImageInfo.Add(new RoomImageInfo
                    {
                        ImgUrl = item.ImgUrl,
                        Id = room.Id,
                    });
                }
                model.RoomArea = room.RoomArea;
                model.Smoke = room.Smoke;
                model.AirportTransfer = room.AirportTransfer;
                model.Bathtub = room.Bathtub;
                model.BedType1 = room.BedType1;
                model.BedType2 = room.BedType2;
                model.BedType3 = room.BedType3;
                model.BedType4 = room.BedType4;
                model.Child = room.Child;
                model.Computer = room.Computer;
                model.Elevator = room.Elevator;
                model.Fridge = room.Fridge;
                model.Guide = room.Guide;
                model.HotWater = room.HotWater;
                model.Intercom = room.Intercom;
                model.IsBasement = room.IsBasement;
                model.LeftLuggage = room.LeftLuggage;
                model.Older = room.Older;
                model.Police = room.Police;
                model.PrivateBathroom = room.PrivateBathroom;
                model.PublicBathroom = room.PublicBathroom;
                model.RoomBalcony = room.RoomBalcony;
                model.RoomCity = room.RoomCity;
                model.RoomCount = room.RoomCount;
                model.RoomDetailedAddress = room.RoomDetailedAddress;
                model.RoomKitchen = room.RoomKitchen;
                model.RoomLang = room.RoomLang;
                model.RoomLong = room.RoomLong;
                model.Shower = room.Shower;
                model.RoomNumber = room.RoomNumber;
                model.RoomShi = room.RoomShi;
                model.RoomSpace = room.RoomSpace;
                model.RoomTing = room.RoomTing;
                model.RoomType = room.RoomType;
                model.Slippers = room.Slippers;
                model.Toiletries = room.Toiletries;
                model.Towel = room.Towel;
                model.WashingMechine = room.WashingMechine;
                model.Water = room.Water;
                model.RoomName = room.RoomName;
                model.RoomNameEN = room.RoomNameEN;
                model.RoomNameTW = room.RoomNameTW;
                return _unitOfWork.Commit() > 0;
            }
            return false;
        }