示例#1
0
        /// <summary>
        /// Populates the selection lists for the events controller
        /// </summary>
        private void PopulateSelectionLists()
        {
            //populates the host dropdown with  clubs drom db
            List <SelectListItem> clubs = SQLUtilities.GetAllHosts();

            ViewData["ClubHosts"] = clubs;

            //Gets all the categories and creates selection list
            List <SelectListItem> cats = SQLUtilities.GetCategories();

            ViewData["cats"] = cats;

            List <SelectListItem> camp = new List <SelectListItem>();

            camp.Add(new SelectListItem()
            {
                Value = "1", Text = "Stevens Point"
            });
            camp.Add(new SelectListItem()
            {
                Value = "2", Text = "Wisconsin Rapids"
            });
            camp.Add(new SelectListItem()
            {
                Value = "3", Text = "Marshfield"
            });
            camp.Add(new SelectListItem()
            {
                Value = "4", Text = "Adams"
            });
            camp.Add(new SelectListItem()
            {
                Value = "5", Text = "Off Campus"
            });

            ViewData["campuses"] = camp;
        }
示例#2
0
        /// <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)));
        }