public ActionResult ReservationPage(int id) { if (Session["Id"] != null && (Session["UserRank"].ToString() == "Customer" || Session["UserRank"].ToString() == "Admin")) { var autoInDb = _context.Automobiles .Include(a => a.NumberOfDoor) .Include(a => a.CarBody) .Include(a => a.Gearshift).SingleOrDefault(a => a.Id == id); if (autoInDb != null) { var viewModel = new ShowReservationViewModel { Automobile = autoInDb, Offers = _context.Offers.Where(o => o.Automobile.Id == autoInDb.Id).ToList(), Reservations = _context.Reservations.Where(r => r.Automobile.Id == autoInDb.Id).ToList() }; return(View("ReservationForm", viewModel)); } else { return(HttpNotFound()); } } else { Session["ResPageId"] = id; return(RedirectToAction("Index", "Login")); } }
// GET: Admin/ReservationManagement public ActionResult Index() { ShowReservationViewModel model = new ShowReservationViewModel { BookList = _booksManagement.GetAll(b => b.DepartureDate == null).OrderBy(b => b.ArrivalDate).ToList(), OldBookList = _booksManagement.GetAll(b => b.DepartureDate != null).OrderBy(b => b.ArrivalDate).ToList() }; return(View(model)); }