public ViewResult Index()
        {
            var session = new OlympicSession(HttpContext.Session);
            var model   = new CountryListViewModel
            {
                ActiveGame     = session.GetActiveGame(),
                ActiveCategory = session.GetActiveCategory(),
                Countries      = session.GetMyCountries()
            };

            return(View(model));
        }
示例#2
0
        public IActionResult Index()
        {
            var session = new OlympicSession(HttpContext.Session);
            var model   = new OlympicListViewModel
            {
                ActiveGame  = session.GetActiveGame(),
                ActiveSport = session.GetActiveSport(),
                Countries   = session.GetMyCountries()
            };

            return(View(model));
        }
示例#3
0
        public RedirectToActionResult Add(CountryViewModel model)
        {
            model.Country = context.Countries
                            .Include(c => c.Sport)
                            .Include(c => c.Game)
                            .Where(c => c.CountryID == model.Country.CountryID)
                            .FirstOrDefault();

            var session   = new OlympicSession(HttpContext.Session);
            var countries = session.GetMyCountries();

            countries.Add(model.Country);
            session.SetMyCountries(countries);

            TempData["message"] = $"{model.Country.Name} added to your favorites";

            return(RedirectToAction("Index",
                                    new
            {
                ActiveSport = session.GetActiveSport(),
                ActiveGame = session.GetActiveGame()
            }));
        }