Ejemplo n.º 1
0
        //put data into MyTeamDetailsViewModel
        private async Task <MyTeamDetailsViewModel> GetMyTeamDetailsViewModel(Team team)
        {
            MyTeamDetailsViewModel viewModel = new MyTeamDetailsViewModel();

            viewModel.Team = team;

            List <ApplicationUser> usersInTeam = await _context.Users
                                                 .Where(m => m.MyTeam == team).ToListAsync();

            viewModel.ApplicationUsers = usersInTeam;
            return(viewModel);
        }
        // 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));
        }
Ejemplo n.º 3
0
        // GET: Teams/MyTeam/5
        public async Task <IActionResult> MyTeam(Team team)
        {
            var CurrentUser = new ApplicationUser();

            CurrentUser = await GetCurrentUserAsync();

            if (CurrentUser == null)
            {
                return(NotFound());
            }

            await _context.Entry(CurrentUser).Reference(x => x.MyTeam).LoadAsync(); //explicitly load myTeam because of lazy loading

            if (CurrentUser.MyTeam == null)
            {
                return(NotFound());
            }

            MyTeamDetailsViewModel viewModel = await GetMyTeamDetailsViewModel(CurrentUser.MyTeam);

            return(View(viewModel));
        }