Example #1
0
        public ActionResult ProccedToPayment(Reservation reservation)
        {
            if (!(_reservationsRepository.CheckReservation(reservation)))
            {
                ViewBag.MessageAvailability = "This room is not available in this period";

                return(RedirectToAction("Create", "Reservations", new{ id = reservation.RoomId }));
            }
            if ((!(_reservationsRepository.IsValid(reservation.ArrivalDate))) || (!(_reservationsRepository.IsValid(reservation.ArrivalDate))))
            {
                ViewBag.MessageFutureDates = "Future Dates Please";
                return(RedirectToAction("Create", "Reservations", new{ id = reservation.RoomId }));
            }

            reservation.UserId          = User.Identity.GetUserId();
            reservation.ApplicationUser = db.Users.FirstOrDefault(x => x.Id == reservation.UserId);

            reservation.RoomId = _roomsRepository.FindById(reservation.RoomId).Id;
            reservation.Room   = _roomsRepository.FindById(reservation.RoomId);

            if (Session[strReservation] == null)
            {
                Session[strReservation] = reservation;
            }

            return(View(reservation));
        }
Example #2
0
        public ActionResult AvailableRooms(SearchViewModel vm)
        {
            if ((!(_reservationsRepository.IsValid(vm.ArrivalDate))) || (!(_reservationsRepository.IsValid(vm.ArrivalDate))))
            {
                return(RedirectToAction("Index", "Home"));
            }

            vm.Rooms = _roomsRepository.GetAllFreeRooms(vm.ArrivalDate, vm.DepartureDate);

            return(View(vm));
        }
Example #3
0
        public ActionResult GetFreeRooms(SearchViewModel vm)
        {
            if ((!(_reservationsRepository.IsValid(vm.ArrivalDate))) || (!(_reservationsRepository.IsValid(vm.ArrivalDate))))
            {
                return(RedirectToAction("Index", "Home"));
            }
            vm.Rooms = _roomsRepository.GetFreeRooms(vm.ArrivalDate, vm.DepartureDate, vm.Room.RoomType);
            if (vm.Rooms.Count() == 0)
            {
                ViewBag.RoomsAvailability = "No Rooms Available in this period";
            }

            return(View(vm));
        }