Esempio n. 1
0
        public ActionResult Attending()
        {
            var userId = User.Identity.GetUserId();

            // Build view model
            var viewModel = new CoopsViewModel()
            {
                UpcomingCoops = _unitOfWork.Coops.GetCoopsUserAttending(userId),
                ShowActions   = User.Identity.IsAuthenticated,
                Heading       = "Co-op sessions I'm Attending",
                Attendances   = _unitOfWork.Attendances.GetFutureAttendances(userId).ToLookup(a => a.CoopId)               // .ToLookup() = convert the list to a data structure that allows us to quickly look up attendances by coop ID. *NOTE: A "LookUp" is like a dictionary - internally it uses a hash table to quickly look up objects
            };

            return(View("Coops", viewModel));
        }
Esempio n. 2
0
        public ActionResult Index(string query = null)
        {
            // Get list of upcoming co-op sessions, providing an optional search query
            var upcomingCoops = _unitOfWork.Coops.GetUpcomingCoops(query);

            // Get attendances to future co-op sessions for the current user
            var userId      = User.Identity.GetUserId();
            var attendances = _unitOfWork.Attendances.GetFutureAttendances(userId)
                              .ToLookup(a => a.CoopId);   // .ToLookup() = convert the list to a data structure that allows us to quickly look up attendances by coop ID. *NOTE: A "LookUp" is like a dictionary - internally it uses a hash table to quickly look up objects

            // Create view model
            var viewModel = new CoopsViewModel
            {
                UpcomingCoops = upcomingCoops,
                ShowActions   = User.Identity.IsAuthenticated,
                Heading       = "Upcoming Co-op sessions",
                SearchTerm    = query,              // autopopulate search box w/ the value of any query, if present
                Attendances   = attendances
            };

            return(View("Coops", viewModel));
        }
Esempio n. 3
0
 public ActionResult Search(CoopsViewModel viewModel)
 {
     return(RedirectToAction("Index", "Home", new { query = viewModel.SearchTerm }));
 }