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)); }
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)); }
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 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() })); }
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() })); }
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() })); }