public bool UpdateRoomDetails(RoomSetupViewModel viewModel)
        {
            var roomDetailsModel = new RoomDetailsModel()
            {
                HotelName      = viewModel.HotelName,
                BookingAddress = viewModel.BookingAddress,
                RoomNumber     = viewModel.RoomNumber,
                RoomType       = viewModel.RoomType,
                RoomStatus     = viewModel.RoomStatus,
                RoomRate       = viewModel.RoomRate,
                NoOfPerson     = viewModel.NoOfPerson,
                DateTime       = DateTime.UtcNow,
            };

            Repository.UpdateRoomInformation(roomDetailsModel);
            return(true);
        }
Esempio n. 2
0
        public Guid UpdateRoomInformation(RoomDetailsModel model)
        {
            var entity = new RoomDetails()
            {
                HotelName      = model.HotelName,
                BookingAddress = model.BookingAddress,
                RoomNumber     = model.RoomNumber,
                RoomType       = model.RoomType,
                RoomStatus     = model.RoomStatus,
                RoomRate       = model.RoomRate,
                NoOfPerson     = model.NoOfPerson,
                DateTime       = DateTime.UtcNow,
            };

            Context.RoomDetails.Add(entity);
            Context.SaveChanges();
            return(entity.Id);
        }
Esempio n. 3
0
        public IActionResult Room(string checkin, string checkout, int roomId)
        {
            RoomDetailsModel roomDetails = new RoomDetailsModel
            {
                Details = _context.Room.Where(room => room.RoomId == roomId).FirstOrDefault(),
                Reviews = _context.Reviews.Where(review => review.RoomId == roomId).ToList()
            };

            var model = new Hotel.Models.BookingModel
            {
                RoomId       = roomId,
                RoomDetails  = roomDetails,
                CheckInDate  = checkin,
                CheckOutDate = checkout,
            };

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult RoomDetails(string motelID)
        {
            var account = new Account();

            if (Session["account"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                account = Session["account"] as Account;
                if (account.Role == 0)
                {
                    return(RedirectToAction("AllPost", "Admin"));
                }
                else if (account.Role == 2)
                {
                    return(RedirectToAction("ChangeInfo", "Account"));
                }
            }
            var ID = 0;

            if (motelID != null)
            {
                ID = int.Parse(motelID);
            }
            var billExist = db.Bills.SingleOrDefault(p => p.MotelID == ID);

            if (billExist != null)
            {
                var dateCurrent     = DateTime.Now;
                var listBillDetails = db.BillDetails.Where(p => p.BillID == billExist.BillID).ToList();
                var n          = listBillDetails.Count();
                var toDayFinal = listBillDetails[n - 1].ToDay;
                var period     = (dateCurrent - toDayFinal).Value.Days;
                if (period > 0)
                {
                    var buildDetails = new BillDetail()
                    {
                        BillID     = billExist.BillID,
                        BillStatus = false,
                        FromDay    = toDayFinal.Value.AddDays(1),
                        ToDay      = toDayFinal.Value.AddDays(31),
                        RoomRates  = db.MotelRooms.SingleOrDefault(p => p.MotelID == ID).Price
                    };
                    db.BillDetails.Add(buildDetails);
                    db.SaveChanges();
                }
            }
            var x = db.MotelRooms.SingleOrDefault(p => p.MotelID == ID && p.AccountID == account.AccountID);

            ViewBag.totalPeople = db.Renters.Where(p => p.MotelID == ID).Count();
            ViewBag.maxPeople   = db.MotelRooms.SingleOrDefault(p => p.MotelID == ID).MaxPeople;
            if (x != null)
            {
                ViewBag.motelID     = ID;
                ViewBag.motelStatus = x.StatusID;
                account             = Session["account"] as Account;
                var listRenter      = db.Renters.Where(p => p.MotelID == ID).ToList();
                var bill            = db.Bills.SingleOrDefault(p => p.MotelID == ID);
                var room            = db.MotelRooms.SingleOrDefault(p => p.MotelID == ID);
                var listBillDetails = new List <BillDetail>();
                if (bill != null)
                {
                    listBillDetails = db.BillDetails.Where(p => p.BillID == bill.BillID).ToList();
                }
                RoomDetailsModel roomDetailsModel = new RoomDetailsModel()
                {
                    Bill           = bill,
                    ListRenter     = listRenter,
                    MotelRoom      = room,
                    ListBillDetail = listBillDetails
                };
                return(View(roomDetailsModel));
            }
            else
            {
                return(RedirectToAction("MotelRooms", "User"));
            }
        }