public IActionResult Picks(int?id) { var picks = context.Pick.Where(p => p.PlayerId == id && p.Week == week).ToList(); if (picks.Count() > 0) { var player = context.Players.FirstOrDefault(m => m.PlayerId == id); //ViewBag.status = "Not Found"; var tieBreaker = picks[0].TieBreaker; List <string> teamAbr = new List <string>(); foreach (var pick in picks) { string abr = MatchupDataHelper.GetTeamAbr(pick.PlayerPick); teamAbr.Add("/img/nfl-logo/" + abr + ".png"); } ViewBag.player = player; ViewBag.picks = picks; ViewBag.abr = teamAbr; ViewBag.tieBreaker = tieBreaker; return(View("Details", player)); } else { var matchups = MatchupDataHelper.Load_Matchups(week); var player = context.Players.FirstOrDefault(m => m.PlayerId == id); ViewBag.playerId = id; ViewBag.player = player; return(View(matchups)); } }
public IActionResult Index(string _week) { var matchups = MatchupDataHelper.Load_Matchups(_week); ViewBag.week = _week; return(View(matchups)); }
public IActionResult SavePicks(int?id, string[] teams, string tiebreaker) { string today_Date = DateTime.Now.ToString("M/d/yyy"); var matchups = MatchupDataHelper.Load_Matchups(week); int matchupCount = matchups.Count(); if (matchupCount != teams.Length || tiebreaker == null) { return(View(nameof(NotSaved))); } var picks = context.Pick.Where(p => p.PlayerId == id && p.Week == week); int _tie; bool tieSucess = int.TryParse(tiebreaker, out _tie); bool status = false; if (picks.Count() > 0) { return(RedirectToAction(nameof(AlreadyPicked))); } else { if (id != null && teams.Length > 0) { var player = context.Players.Find(id); foreach (var team in teams) { Pick pick = new Pick(player.PlayerId, team, _tie, week, "2019"); context.Add(pick); context.SaveChanges(); status = true; } if (status) { ViewBag.player = player; return(RedirectToAction(nameof(PicksSaved))); } else { return(RedirectToAction(nameof(NotSaved))); } } else { return(RedirectToAction(nameof(NotSaved))); } } }