/// <summary> /// The AllEvents /// </summary> /// <param name="sortOrder">The sortOrder<see cref="string"/></param> /// <param name="currentFilter">The currentFilter<see cref="string"/></param> /// <param name="searchString">The searchString<see cref="string"/></param> /// <param name="page">The page<see cref="int?"/></param> /// <returns>The <see cref="ActionResult"/></returns> public ActionResult AllEvents(string sortOrder, string currentFilter, string searchString, int?page) { ViewBag.NavTag = "Events"; // Gets the categories for the filters MintContext db = new MintContext(); ViewData["Categories"] = SQLUtilities.GetCategories(); // Searching string search = null; if (Request.QueryString["search"] != null) { search = Request.QueryString["search"]; } // Categories int?Category = null; if (Request.QueryString["category"] == "0") { Category = null; } else if (Request.QueryString["category"] != null) { Category = Convert.ToInt32(Request.QueryString["category"]); } //Free Stuff/Food bool?FreeFood = null; bool?FreeStuff = null; if (Request.QueryString["freefood"] != null) { FreeFood = true; } if (Request.QueryString["freestuff"] != null) { FreeStuff = true; } // Date string Date = null; if (Request.QueryString["Date"] != null) { Date = Request.QueryString["Date"].ToString(); } bool?Weekend = null; if (Request.QueryString["Weekend"] != null) { Weekend = true; } // Paging info if (searchString != null) { page = 1; } else { searchString = currentFilter; } int pageSize = 9; int pageNumber = (page ?? 1); // Gets all the events for the page var events = SQLUtilities.GetAllEvents(search, Category, FreeFood, FreeStuff, Date, Weekend); //Sets the viewbag info ViewBag.SearchTerm = search; ViewBag.Category = Category; ViewBag.Date = Date; ViewBag.FreeStuff = FreeStuff == null ? "" : "checked"; ViewBag.FreeFood = FreeFood == null ? "" : "checked"; ViewBag.Weekend = Weekend == null ? "" : "checked"; // Returns the view return(View(events.ToPagedList(pageNumber, pageSize))); }