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)); }
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)); }
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() })); }