Ejemplo 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()
            }));
        }
Ejemplo n.º 2
0
        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()
            }));
        }
Ejemplo n.º 3
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()
            }));
        }
Ejemplo n.º 4
0
        public ViewResult Index()
        {
            var session = new CountrySession(HttpContext.Session);
            var model   = new CountryListViewModel
            {
                ActiveGame = session.GetActiveGame(),
                ActiveCat  = session.GetActiveCat(),
                Countries  = session.GetMyCountries()
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public RedirectToActionResult Add(CountryViewModel model)
        {
            model.Country = context.Countries
                            .Include(c => c.Game)
                            .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);

            return(RedirectToAction("Index",
                                    new
            {
                ActiveGame = session.GetActiveGame(),
                ActiveCat = session.GetActiveCat()
            }));
        }