public IActionResult Index()
        {
            var session = new NFLSession(HttpContext.Session);
            var model   = new TeamListViewModel
            {
                ActiveConference = session.GetActiveConference(),
                ActiveDivision   = session.GetActiveDivision(),
                Teams            = session.GetTeams()
            };

            return(View(model));
        }
Beispiel #2
0
        public RedirectToActionResult Add(TeamViewModel model)
        {
            model.Team = _ctx.Teams.Include(c => c.Conference)
                         .Include(d => d.Division)
                         .Where(t => t.TeamID == model.Team.TeamID)
                         .FirstOrDefault();

            var session = new NFLSession(HttpContext.Session);
            var teams   = session.GetTeams();

            teams.Add(model.Team);
            session.SetTeams(teams);

            var cookies = new NFLCookies(Response.Cookies);

            cookies.SetMyTeamsIds(teams);

            TempData["message"] = $"{model.Team.Name} was added to your favorites";

            return(RedirectToAction("Index", new { activeConf = session.GetActiveConference(), activeDiv = session.GetActiveDivision() }));
        }