Esempio n. 1
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 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()
            }));
        }
Esempio n. 2
0
        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()
            }));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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()
            }));
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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()
            }));
        }