public RedirectToActionResult Delete()
        {
            var session = new NFLSession(HttpContext.Session);
            var cookies = new NFLCookies(Response.Cookies);

            session.RemoveMyTeams();
            cookies.RemoveMyTeamIds();

            TempData["Message"] = $"Favorite teams deleted.";

            return(RedirectToAction("Index", "Home", new { ActiveConferend = session.GetActiveConference(), ActiveDivision = session.GetActiveDivision() }));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public RedirectToActionResult Delete()
        {
            var session = new NFLSession(HttpContext.Session);
            var cookies = new NFLCookies(Response.Cookies);

            //remove team from the session and delete that session
            session.RemoveTeam();
            cookies.RemoveTeamId();

            //message to be passed to the redirect route
            TempData["message"] = $"Favorite teams were removed";

            return(RedirectToAction("Index", "Home", new { activeConf = session.GetActiveConference(), activeDiv = session.GetActiveDivision() }));
        }
        public IActionResult Details(string id)
        {
            var session = new NFLSession(HttpContext.Session);

            var model = new TeamViewModel {
                Team = context.Teams.Include(c => c.Conference).Include(d => d.Division).FirstOrDefault(t => t.TeamID == id),

                //ActiveConference = TempData?["ActiveConference"]?.ToString() ?? "all",
                //ActiveDivision = TempData?["ActiveDivision"]?.ToString() ?? "all"

                ActiveConference = session.GetActiveConference(),
                ActiveDivision   = session.GetActiveDivision()
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public IActionResult Details(string Id)
        {
            var session = new NFLSession(HttpContext.Session);

            var model = new TeamViewModel
            {
                Team = _ctx.Teams
                       .Include(conf => conf.Conference)
                       .Include(div => div.Division)
                       .FirstOrDefault(team => team.TeamID == Id),

                ActiveConference = session.GetActiveConference(),
                ActiveDivision   = session.GetActiveDivision()
            };

            return(View(model));
        }
        public RedirectToActionResult Add(TeamViewModel model)
        {
            model.Team = context.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.GetMyTeams();

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

            var cookies = new NFLCookies(Response.Cookies);

            cookies.SetMyTeamIds(teams);

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

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