public ActionResult Index() { var profiler = MiniProfiler.Current; using (profiler.Step("Run Index on HomeController")) { var upcomingGigs = _context.Gigs .Include(g => g.Artist) .Include(g => g.Genre) .Where(g => g.DateTime > DateTime.Now); var userId = User.Identity.GetUserId(); var attendances = _context.Attendances .Where(a => a.AttendeeId == userId && a.Gig.DateTime > DateTime.Now).ToList().ToLookup(a => a.GigId); var viewModel = new GigsViewModel { UpcomingGigs = upcomingGigs, ShowActions = User.Identity.IsAuthenticated, Heading = "Upcoming Gigs", Attendances = attendances }; return View("Gigs", viewModel); } }
public ActionResult Attending() { var userId = User.Identity.GetUserId(); var gigs = _context.Attendances .Where(a => a.AttendeeId == userId) .Select(a => a.Gig) .Include(g => g.Artist) .Include(g => g.Genre) .ToList(); // var attendances = _context.Attendances .Where(a => a.AttendeeId == userId && a.Gig.DateTime > DateTime.Now) .ToList() .ToLookup(a => a.GigId); var viewModel = new GigsViewModel() { UpcomingGigs = gigs, ShowActions = User.Identity.IsAuthenticated, Heading = "Gigs I'm Attending", Attendances = attendances }; return View("Gigs", viewModel); }