public ActionResult Index(string query = null) { var upcomingGos = _context.Gos .Include(g => g.Artical) .Include(g => g.Genre) .Where(g => g.DateTime > DateTime.Now && !g.IsCanceled); if (!String.IsNullOrWhiteSpace(query)) { upcomingGos = upcomingGos .Where(g => g.Artical.Name.Contains(query) || g.Genre.Name.Contains(query) || g.Venue.Contains(query)); } var ViewModel = new GosViewModel { UpcomingGos = upcomingGos, ShowActions = User.Identity.IsAuthenticated, Heading = "Upcoming Gos", SearchTerm = query }; return(View("Gos", ViewModel)); }
public ActionResult Attending() { var userId = User.Identity.GetUserId(); var gos = _context.Attendances .Where(a => a.AttendeeId == userId) .Select(a => a.Go) .Include(g => g.Artical) .Include(g => g.Genre) .ToList(); var ViewModel = new GosViewModel() { UpcomingGos = gos, ShowActions = User.Identity.IsAuthenticated, Heading = "Gos I'm Attending" }; return(View("Gos", ViewModel)); }
public ActionResult Search(GosViewModel viewModel) { return(RedirectToAction("Index", "Home", new { query = viewModel.SearchTerm })); }