public RedirectToActionResult Add(OlympicViewModel model) { model.Country = context.Countries .Include(t => t.Game) .Include(t => t.Sport) .Where(t => t.CountryID == model.Country.CountryID) .FirstOrDefault(); var session = new OlympicSession(HttpContext.Session); var countries = session.GetMyCountries(); countries.Add(model.Country); session.SetMyCountries(countries); /*creates new OlympicCookies object with the controller's response object. * calls SetMyCountryIds and passes updated list of Country objects. */ var cookies = new OlympicCookies(Response.Cookies); cookies.SetMyCountryIds(countries); TempData["message"] = $"{model.Country.CountryName} added to your favorites"; //message return(RedirectToAction("Index", //redirection new { ActiveGame = session.GetActiveGame(), ActiveSport = session.GetActiveSport() })); }
public RedirectToActionResult Add(CountryViewModel model) { model.Country = context.Countries .Include(t => t.Game) .Include(t => t.Category) .Include(t => t.Sport) .Where(t => t.CountryID == model.Country.CountryID) .FirstOrDefault(); var session = new OlympicSession(HttpContext.Session); var countries = session.GetMyCountries(); countries.Add(model.Country); session.SetMyCountries(countries); var cookies = new OlympicCookies(HttpContext.Response.Cookies); cookies.SetMyCountryIds(countries); TempData["message"] = $"{model.Country.Name} added to your favorites"; return(RedirectToAction("Index", new { ActiveGame = session.GetActiveGame(), ActiveCatg = session.GetActiveCatg(), ActiveSport = session.GetActiveSport() })); }
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 ViewResult Details(string id) { var session = new OlympicSession(HttpContext.Session); var model = new OlympicViewModel { Country = context.Countries .Include(t => t.Game) .Include(t => t.Sport) .FirstOrDefault(t => t.CountryID == id), ActiveSport = session.GetActiveGame(), ActiveGame = session.GetActiveSport() }; return(View(model)); }
public RedirectToActionResult Delete() { var session = new OlympicSession(HttpContext.Session); session.RemoveMyCountries(); TempData["message"] = "Favorite teams cleared"; return(RedirectToAction("Index", "Home", new { ActiveSport = session.GetActiveSport(), ActiveGame = session.GetActiveGame() })); }
public ViewResult Details(string id) { var session = new OlympicSession(HttpContext.Session); var model = new CountryViewModel { Country = context.Countries .Include(c => c.Game) .Include(c => c.Sport) .FirstOrDefault(c => c.CountryID == id), //ActiveSport = TempData.Peek("ActiveSport").ToString() , //ActiveGame = TempData.Peek("ActiveGame").ToString() ActiveSport = session.GetActiveSport(), ActiveGame = session.GetActiveGame() }; return(View(model)); }
public RedirectToActionResult Delete() { var session = new OlympicSession(HttpContext.Session); var cookies = new OlympicCookies(Response.Cookies); session.RemoveMyCountries(); cookies.RemoveMyCountryIds(); TempData["message"] = "Favorite countries cleared"; return(RedirectToAction("Index", "Home", new { ActiveGame = session.GetActiveGame(), ActiveCatg = session.GetActiveCatg(), ActiveSport = session.GetActiveSport() })); }