public ActionResult Index()
        {
            var repo  = new TeamRepo();
            var teams = repo.GetTeams(1);

            return(View(teams));
        }
        public ActionResult AddTeam()
        {
            var repo = new TeamRepo();
            var VM   = new AddTeamVM();

            VM.TeamList = repo.GetTeams(1);

            return(View(VM));
        }
Example #3
0
        public static List <Game> GetGamesForWeek(int week, int year)
        {
            var games = GameRepo.GetGamesForWeek(week, year);
            var teams = TeamRepo.GetTeams();

            foreach (var game in games)
            {
                game.HomeTeam = teams.GetValueOrDefault(game.HomeId);
                game.AwayTeam = teams.GetValueOrDefault(game.AwayId);
            }

            return(games);
        }
Example #4
0
        public static List <Matchup> GetMatchupsForWeek(int week, int year)
        {
            var            teams         = TeamRepo.GetTeams();
            var            matchups      = ScheduleRepo.GetMatchupsForWeek(week, year);
            List <Matchup> matchups_copy = new List <Matchup>();

            foreach (var matchup in matchups)
            {
                matchup.HomeTeam   = teams.GetValueOrDefault(matchup.HomeTeamID);
                matchup.AwayTeam   = teams.GetValueOrDefault(matchup.AwayTeamID);
                matchup.Multiplier = 1;
                if (matchup.HomeTeam != null && matchup.AwayTeam != null)
                {
                    matchups_copy.Add(matchup);
                }
            }

            return(matchups_copy.OrderByDescending(x => x.AwayTeam.School == "Michigan" || x.HomeTeam.School == "Michigan")
                   .ThenByDescending(x => x.AwayTeam.School == "Michigan State" || x.HomeTeam.School == "Michigan State")
                   .ThenByDescending(x => x.AwayTeam.School == "Ohio State" || x.HomeTeam.School == "Ohio State").ToList());
        }
Example #5
0
        public static ResultsResponse GetResultsForWeek(int week, int year)
        {
            var result     = new ResultsResponse();
            var resultRows = new List <ResultsRow>();

            var users    = UserRepo.GetUsers();
            var games    = GameRepo.GetGamesForWeek(week, year);
            var teams    = TeamRepo.GetTeams();
            var matchups = ScheduleRepo.GetMatchupsForWeek(week, year);

            foreach (var game in games)
            {
                game.HomeTeam = teams.GetValueOrDefault(game.HomeId);
                game.AwayTeam = teams.GetValueOrDefault(game.AwayId);
                game.DateTime = matchups.Where(x => x.HomeTeamID == game.HomeId).Select(x => x.DateTime).FirstOrDefault();
                game.Day      = matchups.Where(x => x.HomeTeamID == game.HomeId).Select(x => x.Day).FirstOrDefault();

                if (game.Outcome == "Home")
                {
                    game.HomeTeam.Outcome = "Win";
                    game.AwayTeam.Outcome = "Lose";
                }
                else if (game.Outcome == "Away")
                {
                    game.AwayTeam.Outcome = "Win";
                    game.HomeTeam.Outcome = "Lose";
                }
            }

            foreach (var user in users)
            {
                if (user.Picks != null)
                {
                    var pick = user.Picks.Where(x => x.WeekNum == week && x.Year == year).FirstOrDefault();
                    if (pick != null)
                    {
                        var prevPick = new Pick();
                        if (week == 1)
                        {
                            prevPick = pick;
                        }
                        else
                        {
                            prevPick = user.Picks.Where(x => x.WeekNum == week - 1 && x.Year == year).FirstOrDefault();
                        }

                        var userTeams = new List <Team>();

                        foreach (var game in pick.Winners)
                        {
                            userTeams.Add(teams[game]);
                        }

                        user.Password = "";
                        user.Picks    = null;

                        resultRows.Add(new ResultsRow()
                        {
                            BestBetId = pick.BestBet,
                            Rank      = prevPick.Rank,
                            Teams     = userTeams,
                            User      = user
                        });
                    }
                }
            }

            result.Rows = resultRows.OrderBy(x => x.Rank).ToList();

            result.Games = games;

            return(result);
        }
Example #6
0
        public IActionResult Get(Guid id)
        {
            var result = _teamRepo.GetTeams(id);

            return(Ok(result));
        }