示例#1
0
        public IActionResult Details(CountryViewModel model)
        {
            model.Country = context.Countries
                            .Include(t => t.Category)
                            .Include(t => t.Game)
                            .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.Name} added to your favorites";

            return(RedirectToAction("Index",
                                    new
            {
                ActiveCat = session.GetActiveCat(),
                ActiveGam = session.GetActiveGam()
            }));
        }
        public ViewResult Index()
        {
            var session = new CountrySession(HttpContext.Session);
            var model   = new CountryListViewModel
            {
                ActiveCat = session.GetActiveCat(),
                ActiveGam = session.GetActiveGam(),
                Countries = session.GetMyCountries()
            };

            return(View(model));
        }
示例#3
0
        public IActionResult Details(string id)
        {
            var session = new CountrySession(HttpContext.Session);
            var model   = new CountryViewModel
            {
                Country = context.Countries
                          .Include(t => t.Category)
                          .Include(t => t.Game)
                          .FirstOrDefault(t => t.CountryID == id),
                ActiveGam = session.GetActiveGam(),
                ActiveCat = session.GetActiveCat()
            };

            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 countries cleared";

            return(RedirectToAction("Index", "Home",
                                    new
            {
                ActiveCat = session.GetActiveCat(),
                ActiveGam = session.GetActiveGam()
            }));
        }