Exemplo n.º 1
0
        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()
            }));
        }
Exemplo n.º 2
0
        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 CountryListViewModel
            {
                ActiveGame     = session.GetActiveGame(),
                ActiveSport    = session.GetActiveSport(),
                ActiveCategory = session.GetActiveCategory(),
                Countries      = session.GetMyCountries(),
                UserName       = session.GetName()
            };

            return(View(model));
        }
Exemplo n.º 4
0
        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(HttpContext.Response.Cookies);

            session.RemoveMyCountries();
            cookies.RemoveMyCountryIds();

            TempData["message"] = "Favorite countries cleared";

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