// GET: MyTeams/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var viewModel = new MyTeamDetailsViewModel();

            viewModel.MyTeam = await _myTeamService.GetMyTeamByIDAsync(id.Value);

            if (viewModel.MyTeam == null)
            {
                return(NotFound());
            }
            viewModel.Roster = await _playerMyTeamService.GetRosterDictionaryAsync(viewModel.MyTeam.MyTeamID);

            return(View(viewModel));
        }
        public async Task <ActionResult> GetRoster([FromQuery] int matchId)
        {
            var viewModel = new FantasyMatchupDetailsRostersViewModel();

            viewModel.FantasyMatchup = await _fantasyMatchupService.GetMatchupByIDAsync(matchId);

            var matchupWeek = await _fantasyMatchupsWeeksService.GetFantasyMatchupWeekByLeagueAsync(viewModel.FantasyMatchup.FantasyLeagueID, viewModel.FantasyMatchup.Week);

            var homeRosterTask = _playerMyTeamService.GetRosterDictionaryAsync(viewModel.FantasyMatchup.HomeTeamID.Value);
            var awayRosterTask = _playerMyTeamService.GetRosterDictionaryAsync(viewModel.FantasyMatchup.AwayTeamID.Value);
            var rosterTasks    = new List <Task> {
                homeRosterTask, awayRosterTask
            };

            while (rosterTasks.Any())
            {
                Task finsihed = await Task.WhenAny(rosterTasks);

                if (finsihed == homeRosterTask)
                {
                    rosterTasks.Remove(homeRosterTask);
                    viewModel.HomeRoster = await homeRosterTask;
                }
                else if (finsihed == awayRosterTask)
                {
                    rosterTasks.Remove(awayRosterTask);
                    viewModel.AwayRoster = await awayRosterTask;
                }
                else
                {
                    rosterTasks.Remove(finsihed);
                }
            }
            var homeOppTask   = _fantasyMatchupService.GetOpponentLogoDictionaryAsync(viewModel.HomeRoster, matchupWeek);
            var awayOppTask   = _fantasyMatchupService.GetOpponentLogoDictionaryAsync(viewModel.AwayRoster, matchupWeek);
            var homeStatsTask = _fantasyMatchupService.GetGameStatsDictionaryAsync(viewModel.HomeRoster, matchupWeek);
            var awayStatsTask = _fantasyMatchupService.GetGameStatsDictionaryAsync(viewModel.AwayRoster, matchupWeek);

            var viewTasks = new List <Task> {
                homeStatsTask, awayStatsTask, homeOppTask, awayOppTask
            };

            while (viewTasks.Any())
            {
                Task finished = await Task.WhenAny(viewTasks);

                if (finished == homeStatsTask)
                {
                    viewTasks.Remove(homeStatsTask);
                    viewModel.HomeStats = await homeStatsTask;
                }
                else if (finished == awayStatsTask)
                {
                    viewTasks.Remove(awayStatsTask);
                    viewModel.AwayStats = await awayStatsTask;
                }
                else if (finished == homeOppTask)
                {
                    viewTasks.Remove(homeOppTask);
                    viewModel.HomeOpp = await homeOppTask;
                }
                else if (finished == awayOppTask)
                {
                    viewTasks.Remove(awayOppTask);
                    viewModel.AwayOpp = await awayOppTask;
                }
                else
                {
                    viewTasks.Remove(finished);
                }
            }
            return(PartialView("_DetailsPartial", viewModel));
        }