// GET: Agents public async Task <IActionResult> Index(Guid id) { Guid ID = id; if (ID == Guid.Empty) { var temp = _userinfo.GetActiveHotels().FirstOrDefault(); ID = Guid.Parse(temp.ToString()); } if (ID == Guid.Empty) { return(NotFound()); } var welcomeContext = _context.Agents.Include(a => a.Hotel).Where(r => r.HotelID == ID); ViewBag.HotelID = ID; return(View(await welcomeContext.ToListAsync())); }
// GET: RoomTypes public async Task <IActionResult> Index(Guid id) { if (id == Guid.Empty) { id = _userinfo.GetActiveHotels().FirstOrDefault(); } if (id == Guid.Empty) { return(NotFound()); } var welcomeContext = _context.RoomTypes.OrderBy(r => r.DisplayOrder).ThenBy(r => r.Abbreviation).Include(r => r.Hotel).Where(s => s.HotelID == id); ViewBag.HotelID = id; return(View(await welcomeContext.ToListAsync())); }
// GET: Hotels public async Task <IActionResult> Index(Guid?id) { if (id == null) { Hotel activehotel = _context.Hotels.SingleOrDefault(s => s.HotelID == _userinfo.GetActiveHotels().FirstOrDefault()); IQueryable <Hotel> userhotels = _context.Hotels.Include(h => h.HotelGroup).Where(s => s.HotelGroupID == activehotel.HotelGroupID); if (!User.IsInRole("Admin")) { userhotels = userhotels.Where(r => _userinfo.HotelIDs.Any(s => s == r.HotelID)); } else { _userinfo.HotelIDs = new Guid[] { id.Value }.ToList(); _userinfo.SetActiveHotels(new Guid[] { id.Value }); } return(View(await userhotels.ToListAsync())); } else { ViewBag.ActiveHotelGroupID = id; if (User.IsInRole("Admin")) { _userinfo.HotelIDs = new Guid[] { id.Value }.ToList(); _userinfo.SetActiveHotels(new Guid[] { id.Value }); } } var welcomeContext = _context.Hotels.Include(h => h.HotelGroup); return(View(await welcomeContext.ToListAsync())); }