コード例 #1
0
        public RedirectToActionResult Change(TeamListViewModel model)
        {
            var session = new NFLSession(HttpContext.Session);

            session.SetName(model.UserName);
            return(RedirectToAction("Index", "Home", new
            {
                ActiveConf = session.GetActiveConf(),
                ActiveDiv = session.GetActiveDiv()
            }));
        }
コード例 #2
0
        public ViewResult Index()
        {
            var session = new NFLSession(HttpContext.Session);
            var model   = new TeamListViewModel
            {
                ActiveConf = session.GetActiveConf(),
                ActiveDiv  = session.GetActiveDiv(),
                Teams      = session.GetMyTeams()
            };

            return(View(model));
        }
コード例 #3
0
        public RedirectToActionResult ClearAllSessions()
        {
            var session = new NFLSession(HttpContext.Session);

            session.ClearSessions();
            return(RedirectToAction("Index",
                                    new
            {
                ActiveConf = session.GetActiveConf(),
                ActiveDiv = session.GetActiveDiv()
            }));
        }
コード例 #4
0
ファイル: FavoritesController.cs プロジェクト: kashdevine/NFL
        public RedirectToActionResult Delete()
        {
            var session = new NFLSession(HttpContext.Session);
            var cookies = new NFLCookies(Response.Cookies);

            session.RemoveMyTeams();
            cookies.RemoveMyTeamsIDs();

            TempData["message"] = "Favorite Teams are cleared";
            return(RedirectToAction("Index", "Home",
                                    new { activeConf = session.GetActiveConf(), activeDiv = session.GetActiveDiv() }));
        }
コード例 #5
0
        public RedirectToActionResult Delete()
        {
            var session = new NFLSession(HttpContext.Session);

            session.RemoveMyTeams();

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

            return(RedirectToAction("Index", "Home",
                                    new {
                ActiveConf = session.GetActiveConf(),
                ActiveDiv = session.GetActiveDiv()
            }));
        }
コード例 #6
0
        public IActionResult Details(string id)
        {
            var session = new NFLSession(HttpContext.Session);
            var model   = new TeamViewModel
            {
                Team = context.Teams
                       .Include(t => t.Conference)
                       .Include(t => t.Division)
                       .FirstOrDefault(t => t.TeamID == id),
                ActiveDiv  = session.GetActiveDiv(),
                ActiveConf = session.GetActiveConf()
            };

            return(View(model));
        }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: kashdevine/NFL
        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 { activeConf = session.GetActiveConf(), activeDiv = session.GetActiveDiv() }));
        }
コード例 #8
0
        public RedirectToActionResult Add(TeamViewModel data)
        {
            data.Team = context.Teams
                        .Include(t => t.Conference)
                        .Include(t => t.Division)
                        .Where(t => t.TeamID == data.Team.TeamID)
                        .FirstOrDefault();

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

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

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

            return(RedirectToAction("Index",
                                    new {
                ActiveConf = session.GetActiveConf(),
                ActiveDiv = session.GetActiveDiv()
            }));
        }