public ActionResult CheckUserPicks(int weekId) { ModelState.Clear(); FootballPoolViewModel vw = FootballPoolFactory.CheckUserPicks(weekId); return(View(vw)); }
public ActionResult UserPicks(int weekId, int simpleUserId) { ModelState.Clear(); FootballPoolViewModel vw = FootballPoolFactory.BuildFootballPoolViewModel(weekId, simpleUserId); return(View(vw)); }
public ActionResult GameScores(int weekId) { ModelState.Clear(); FootballPoolViewModel vw = FootballPoolFactory.BuildFootballPoolViewModel(weekId, 0); return(View(vw)); }
internal static FootballPoolViewModel CheckUserPicks(int weekId) { ApplicationDbContext _db = new ApplicationDbContext(); var userIdList = _db.FootballPoolUser.Select(fp => fp.simpleUserId).ToList(); var usersPicksMade = _db.FootballPoolUserPicks.Where(fp => fp.weekId == weekId).Select(fp => fp.simpleUserId).Distinct().ToList(); var usersPicksNotMade = userIdList.Except(usersPicksMade).ToList(); FootballPoolViewModel vw = new FootballPoolViewModel(); List <FootballGame> gamesThisWeek = _db.FootballGame.Where(fg => fg.weekId == weekId).ToList(); vw.footballGames = gamesThisWeek; List <FootballPoolUsers> users = _db.FootballPoolUser.ToList(); vw.users = users; List <CheckUserPicks> userPickChecks = new List <CheckUserPicks>(); foreach (var user in users) { CheckUserPicks thisUserCheck = new CheckUserPicks() { simpleUserId = user.simpleUserId, weekId = weekId, userName = user.userName }; thisUserCheck.hasMadePicks = usersPicksNotMade.Contains(user.simpleUserId) ? false : true; thisUserCheck.numberOfPicksMade = _db.FootballPoolUserPicks.Where(fp => fp.weekId == weekId && fp.simpleUserId == user.simpleUserId && fp.pick != 0).Count(); userPickChecks.Add(thisUserCheck); } vw.userPicksCheck = userPickChecks.OrderBy(up => up.hasMadePicks); return(vw); }
public IActionResult Index() { FootballPoolViewModel vm = new FootballPoolViewModel(); vm.errors = new List <Alert>(); return(View("JoinLeagueView", vm)); }
public ActionResult MyDashboard() { int simpleUserId = Convert.ToInt32(User.Identity.GetSimpleUserId()); FootballPoolViewModel vw = FootballPoolFactory.GetUserAlerts(simpleUserId); return(View(vw)); }
public FootballPoolViewModel saveBracket([FromBody] Bracket bracket) { List <Alert> errors = matchupService.validateBracket(bracket).ToList(); if (errors.Count == 0) { matchupService.saveBracket(bracket, true); } else { bool hasErrors = false; foreach (Alert a in errors) { if (Alert.DANGER_TYPE.Equals(a.type)) { hasErrors = true; break; } } if (!hasErrors) { matchupService.saveBracket(bracket, true); } } FootballPoolViewModel vm = new FootballPoolViewModel(); vm.errors = errors; vm.bracket = bracket; return(vm); }
public ActionResult WeeklySchedule(int weekId, int simpleUserId) { // int simpleUserId = Convert.ToInt32(User.Identity.GetSimpleUserId()); FootballPoolViewModel vw = FootballPoolFactory.BuildFootballPoolViewModel(weekId, simpleUserId); ViewBag.WeekId = weekId; return(View(vw)); }
internal static FootballPoolViewModel CheckEntryFees() { ApplicationDbContext _db = new ApplicationDbContext(); FootballPoolViewModel vw = new FootballPoolViewModel(); vw.users = _db.FootballPoolUser.ToList(); return(vw); }
internal static FootballPoolViewModel BuildFootballPoolViewModel(int weekId, int simpleUserId) { FootballPoolViewModel footballPoolViewModel = new FootballPoolViewModel() { footballGames = GetWeeklyGames(weekId), userPicks = GetUsersPicks(weekId, simpleUserId), byeWeekTeams = GetByeWeekTeams(weekId) }; return(footballPoolViewModel); }
internal static FootballPoolViewModel BuildAccountProfileViewModel(int simpleUserId) { ApplicationDbContext _db = new ApplicationDbContext(); FootballPoolViewModel vw = new FootballPoolViewModel(); List <FootballPoolUsers> thisUser = _db.FootballPoolUser.Where(u => u.simpleUserId == simpleUserId).ToList(); vw.users = thisUser; return(vw); }
internal static FootballPoolViewModel GetLeaderboard() { ApplicationDbContext _db = new ApplicationDbContext(); FootballPoolViewModel vw = new FootballPoolViewModel() { users = _db.FootballPoolUser.ToList().OrderByDescending(m => m.userScore) }; return(vw); }
internal static FootballPoolViewModel GetUserAlerts(int simpleUserId) { ApplicationDbContext _db = new ApplicationDbContext(); FootballPoolViewModel vw = new FootballPoolViewModel() { alerts = _db.UserAlerts.Where(a => a.simpleUserId == simpleUserId).ToList() }; return(vw); }
public ActionResult SubmitGameScores(FootballPoolViewModel thisVW) { try { FootballPoolFactory.SubmitGameScores(thisVW); FootballPoolFactory.UpdateTeamInfo(); } catch (Exception e) { LoggerFactory.LogError("SubmitGameScores", string.Format("Message: {0} more details: {1}", e.Message, e.InnerException.Message), e.StackTrace, User.Identity.GetSimpleUserId()); } return(RedirectToAction("Index", "Admin")); }
internal static void SubmitGameScores(FootballPoolViewModel thisVW) { ApplicationDbContext _db = new ApplicationDbContext(); foreach (var game in thisVW.footballGames) { FootballGame thisGame = _db.FootballGame.Where(g => g.gameId == game.gameId).FirstOrDefault(); thisGame.awayTeamScore = game.awayTeamScore; thisGame.homeTeamScore = game.homeTeamScore; //determine winning column thisGame = SetWinningAndLossingTeams(thisGame); _db.Entry(thisGame).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } }
public ActionResult AccountProfile(string message) { if (!String.IsNullOrEmpty(message)) { ViewBag.StatusMessage = message; } else { ViewBag.StatusMessage = ""; } int simpleUserId = Convert.ToInt32(User.Identity.GetSimpleUserId()); FootballPoolViewModel vw = FootballPoolFactory.BuildAccountProfileViewModel(simpleUserId); return(View(vw)); }
public IActionResult JoinLeague(string leagueName, string leaguePassword) { string userName = User.Identity.Name; FootballPoolViewModel vm = new FootballPoolViewModel(); List <Alert> errors = matchupService.joinLeague(leagueName ?? "", leaguePassword ?? "", userName ?? ""); if (errors.ToList().Count == 0) { return(RedirectToAction("Index", "Home")); } else { vm.errors = errors; League league = matchupService.getLeagueByUserName(userName); return(View("JoinLeagueView", vm)); } }
public IActionResult GetWeek(int week) { FootballPoolViewModel vm = new FootballPoolViewModel(); string name = User.Identity.Name; League league = matchupService.getLeagueByUserName(name); if (league == null) { return(RedirectToAction("Index", "League")); } vm.weeksInSeason = matchupService.getNumberOfWeeksInSeason(matchupService.getCurrentSeason()); week = week <= 0 ? 1 : week > vm.weeksInSeason ? vm.weeksInSeason : week; vm.bracket = matchupService.getUsersBracketByWeek(name, matchupService.getCurrentSeason(), week, league.id); vm.currentWeek = matchupService.getCurrentWeek(); vm.comments = matchupService.getCommentsRecent(vm.bracket.league_id, 10); return(View("PicksView", vm)); }
public ActionResult Leaderboard() { FootballPoolViewModel vw = FootballPoolFactory.GetLeaderboard(); return(View(vw)); }
public ActionResult CheckEntryFees() { FootballPoolViewModel vw = FootballPoolFactory.CheckEntryFees(); return(View(vw)); }