コード例 #1
0
        public string GetById(long id)
        {
            var hotelId = UserContext.CurrentUser.HotelId;
            //获取房型
            var roomTypeList = RoomTypeBll.GetList(hotelId);

            if (roomTypeList == null)
            {
                roomTypeList = new List <RoomType>();
            }
            if (id == 0)
            {
                return(JsonConvert.SerializeObject(new
                {
                    Model = new RoomYd()
                    {
                        HotelId = hotelId
                    },
                    RoomTypeList = roomTypeList
                }));
            }
            else
            {
                //获取所有预订的房间
                var roomYdRoomList = RoomYdRoomBll.GetLIst(id);
                if (roomYdRoomList != null && roomYdRoomList.Count > 0)
                {
                    //循环获取房间
                    foreach (var roomtype in roomTypeList)
                    {
                        var roomList = roomYdRoomList.Where(m => m.RoomTypeId == roomtype.Id).ToList();
                        if (roomList != null && roomList.Count() > 0)
                        {
                            roomtype.YdRoomList = roomList;
                            //foreach (var room in roomList)
                            //{
                            //    if (room.RoomId != 0)
                            //        roomtype.YdRoomList.Add(new RoomYdRoom() { Id = room.RoomId, RoomNO = room.RoomNO });
                            //}
                            roomtype.RoomPriceId   = roomList.ElementAt(0).RoomPriceId;
                            roomtype.RoomCount     = roomList.ElementAt(0).RoomCount;
                            roomtype.RoomPrice     = roomList.ElementAt(0).Price;
                            roomtype.RoomSale      = roomList.ElementAt(0).Sale;
                            roomtype.RoomSalePrice = roomList.ElementAt(0).SalePrice;
                        }
                        else
                        {
                            roomtype.YdRoomList = new List <RoomYdRoom>();
                            roomtype.RoomCount  = 0;
                        }
                    }
                }
                var info = RoomYdBll.GetById(id);
                return(JsonConvert.SerializeObject(new
                {
                    Model = info,
                    RoomTypeList = roomTypeList
                }));
            }
        }
コード例 #2
0
        /// <summary>
        /// 预订转入住界面的刷新--自动分房和取消分房后的刷新
        /// </summary>
        /// <param name="ydid"></param>
        /// <returns></returns>
        public string YdzrzRefresh(long ydid)
        {
            var info = RoomYdBll.GetById(ydid);

            Model.RoomReg zfRoomReg = null;
            if (info.ZfRoomRegId > 0)
            {
                zfRoomReg = RoomRegBll.GetById(info.ZfRoomRegId);
            }
            var hotelId = UserContext.CurrentUser.HotelId;
            //获取房型
            var roomTypeList = RoomTypeBll.GetList(hotelId);

            if (roomTypeList == null)
            {
                roomTypeList = new List <RoomType>();
            }
            var ydRoomTypeList = new List <RoomType>();
            //获取所有预订的房间
            var roomYdRoomList = RoomYdRoomBll.GetLIst(ydid);

            if (roomYdRoomList != null && roomYdRoomList.Count > 0)
            {
                //循环获取房间
                foreach (var roomtype in roomTypeList)
                {
                    var roomList = roomYdRoomList.Where(m => m.RoomTypeId == roomtype.Id);
                    if (roomList != null && roomList.Count() > 0)
                    {
                        roomtype.YdRoomList = new List <RoomYdRoom>();
                        foreach (var room in roomList)
                        {
                            room.Name = info.Name;
                            room.IsZf = zfRoomReg == null ? false : (room.RoomRegId == zfRoomReg.Id ? true : false);
                            //room.IsZf = room.RoomRegId == zfRoomReg.Id ? true : false;
                            room.YdaoTime = info.YdaoTime;
                            room.YliTime  = info.YliTime;
                            roomtype.YdRoomList.Add(room);
                        }
                        roomtype.RoomCount = roomList.ElementAt(0).RoomCount;
                        //if (roomtype.RoomCount > roomtype.YdRoomList.Count)
                        //{
                        //    for (var p = roomtype.YdRoomList.Count; p < roomtype.RoomCount; p++)
                        //    {
                        //        roomtype.YdRoomList.Add(new RoomYdRoom()
                        //        {
                        //            Id = 0,
                        //            Name = info.Name,
                        //            RoomTypeId = roomtype.Id,
                        //            RoomTypeName = roomtype.Name,
                        //            RoomId = 0,
                        //            RoomNO = "",
                        //            IsZf = false,
                        //            Price = roomtype.YdRoomList.Count > 0 ? roomtype.YdRoomList[0].Price : roomtype.Price,
                        //            Sale = roomtype.YdRoomList.Count > 0 ? roomtype.YdRoomList[0].Sale : 1,
                        //            SalePrice = roomtype.YdRoomList.Count > 0 ? roomtype.YdRoomList[0].SalePrice : roomtype.Price,
                        //            YdaoTime = info.YdaoTime,
                        //            YliTime = info.YliTime,
                        //        });
                        //    }
                        //}
                    }
                    else
                    {
                        continue;
                        //roomtype.YdRoomList = new List<RoomYdRoom>();
                        //roomtype.RoomCount = 0;
                    }
                    ydRoomTypeList.Add(roomtype);
                }
            }
            return(JsonConvert.SerializeObject(ydRoomTypeList));
        }
コード例 #3
0
        public ActionResult Edit(long id = 0)
        {
            var hotelId = UserContext.CurrentUser.HotelId;
            //获取房型
            var roomTypeList = RoomTypeBll.GetList(hotelId);

            if (roomTypeList == null)
            {
                roomTypeList = new List <RoomType>();
            }
            //获取所有房价方案
            var roomPriceList = RoomPriceBll.GetList(hotelId);

            if (roomPriceList == null)
            {
                roomPriceList = new List <RoomPrice>();
            }
            //循环房型获取房型对应的房价方案
            foreach (var roomtype in roomTypeList)
            {
                var roomPriceArr = roomPriceList.Where(m => m.RoomTypeId == roomtype.Id || m.RoomTypeId == 0);
                roomtype.RoomPriceList = roomPriceArr.ToList();
            }
            if (id == 0)
            {
                ViewBag.RoomPriceList = roomPriceList;
                ViewBag.RoomTypeList  = roomTypeList;
                return(View(new RoomYd()
                {
                    HotelId = hotelId
                }));
            }
            else
            {
                //获取所有预订的房间
                var roomYdRoomList = RoomYdRoomBll.GetLIst(id);
                if (roomYdRoomList != null && roomYdRoomList.Count > 0)
                {
                    //循环获取房间
                    foreach (var roomtype in roomTypeList)
                    {
                        var roomList = roomYdRoomList.Where(m => m.RoomTypeId == roomtype.Id);
                        if (roomList != null && roomList.Count() > 0)
                        {
                            roomtype.YdRoomList = new List <RoomYdRoom>();
                            foreach (var room in roomList)
                            {
                                if (room.RoomId != 0)
                                {
                                    roomtype.YdRoomList.Add(room);
                                }
                            }
                            roomtype.RoomCount     = roomList.ElementAt(0).RoomCount;
                            roomtype.RoomPriceId   = roomList.ElementAt(0).RoomPriceIdTip;
                            roomtype.RoomPrice     = roomList.ElementAt(0).PriceTip;
                            roomtype.RoomSale      = roomList.ElementAt(0).SaleTip;
                            roomtype.RoomSalePrice = roomList.ElementAt(0).SalePriceTip;
                        }
                        else
                        {
                            roomtype.YdRoomList    = new List <RoomYdRoom>();
                            roomtype.RoomCount     = 0;
                            roomtype.RoomPrice     = roomtype.Price;
                            roomtype.RoomSale      = decimal.Parse("1.00");
                            roomtype.RoomSalePrice = roomtype.Price;
                        }
                    }
                }

                var info = RoomYdBll.GetById(id);
                ViewBag.RoomPriceList = roomPriceList;
                ViewBag.RoomTypeList  = roomTypeList;
                return(View(info));
            }
        }