Esempio n. 1
0
        public override async Task OnConnectedAsync()
        {
            var currentUser = await _userManager.FindByNameAsync(Context.User.Identity.Name);

            var leagues = await _fantasyCriticService.GetLeaguesForUser(currentUser);

            List <LeagueYear> draftingLeagueYears = new List <LeagueYear>();

            foreach (var league in leagues)
            {
                foreach (var year in league.Years)
                {
                    var leagueYear = await _fantasyCriticService.GetLeagueYear(league.LeagueID, year);

                    if (leagueYear.HasValue && leagueYear.Value.PlayStatus.DraftIsActive)
                    {
                        draftingLeagueYears.Add(leagueYear.Value);
                    }
                }
            }

            foreach (var leagueYear in draftingLeagueYears)
            {
                await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(leagueYear));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> MyLeagues()
        {
            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            IReadOnlyList <League> myLeagues = await _fantasyCriticService.GetLeaguesForUser(currentUser);

            List <LeagueViewModel> viewModels = new List <LeagueViewModel>();

            foreach (var league in myLeagues)
            {
                bool isManager = (league.LeagueManager.UserID == currentUser.UserID);
                viewModels.Add(new LeagueViewModel(league, isManager));
            }

            return(Ok(viewModels));
        }