public RedirectToActionResult Add(CountryViewModel model) { model.Country = context.Countries .Include(c => c.Game) .Include(c => c.Sport) .Include(c => c.Category) .Where(c => c.CountryId == model.Country.CountryId) .FirstOrDefault(); var session = new CountrySession(HttpContext.Session); var Countries = session.GetMyCountries(); Countries.Add(model.Country); session.SetMyCountries(Countries); var cookies = new CountryCookies(HttpContext.Response.Cookies); cookies.SetMyCountryIds(Countries); TempData["message"] = $"{model.Country.Name} added to your favorites"; return(RedirectToAction("Index", new { ActiveGame = session.GetActiveGame(), ActiveSport = session.GetActiveSport(), ActiveCategory = session.GetActiveCategory() })); }
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 CountrySession(HttpContext.Session); var countries = session.GetMyCountries(); countries.Add(model.Country); session.SetMyCountries(countries); var cookies = new CountryCookies(Response.Cookies); cookies.SetMyCountryIds(countries); TempData["message"] = $"{model.Country.CountryName} added to favorites"; return(RedirectToAction("Index", new { ActiveGame = session.GetActiveGame(), ActiveSport = session.GetActiveSport() })); }
public RedirectToActionResult Change(CountryListViewModel model) { var session = new CountrySession(HttpContext.Session); session.SetName(model.UserName); return(RedirectToAction("Index", "Home", new { ActiveGame = session.GetActiveGame(), ActiveSport = session.GetActiveSport(), ActiveCategory = session.GetActiveCategory() })); }
public ViewResult Index() { var session = new CountrySession(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 CountrySession(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 IActionResult Details(string id) { var session = new CountrySession(HttpContext.Session); var model = new CountryViewModel { Country = context.Countries .Include(c => c.Game) .Include(c => c.Sport) .Include(c => c.Category) .FirstOrDefault(c => c.CountryId == id), ActiveSport = session.GetActiveSport(), ActiveGame = session.GetActiveGame(), ActiveCategory = session.GetActiveCategory() }; return(View(model)); }
public RedirectToActionResult Delete() { var session = new CountrySession(HttpContext.Session); var cookies = new CountryCookies(Response.Cookies); session.RemoveMyCountries(); cookies.RemoveMyCountryIds(); TempData["message"] = "Favorite teams cleared"; return(RedirectToAction("Index", "Home", new { ActiveGame = session.GetActiveGame(), ActiveSport = session.GetActiveSport() })); }