// GET: PlayerMyTeams/Create public async Task <IActionResult> Create(int?teamID, string sortParam, string currentFilter, string searchString, int?pageNumber, string posFilter) { var viewModel = new PlayerMyTeamCreateViewModel(); if (teamID == null) { return(NotFound()); } viewModel.MyTeam = await _myTeamsService.GetMyTeamByIDAsync(teamID.Value); var isAuthorized = await _auth.AuthorizeAsync(User, viewModel.MyTeam, Operations.Create); if (!isAuthorized.Succeeded) { return(new ChallengeResult()); } //sort param ViewData["currentSort"] = sortParam; ViewData["playerSort"] = String.IsNullOrEmpty(sortParam) ? "player_desc" : " "; ViewData["fgSort"] = sortParam == "fg_desc" ? "FG" : "fg_desc"; ViewData["ftSort"] = sortParam == "ft_desc" ? "FT" : "ft_desc"; ViewData["3ptSort"] = sortParam == "3pt_desc" ? "3PT" : "3pt_desc"; ViewData["ppgSort"] = sortParam == "ppg_desc" ? "PPG" : "ppg_desc"; ViewData["apgSort"] = sortParam == "apg_desc" ? "APG" : "apg_desc"; ViewData["rpgSort"] = sortParam == "rpg_desc" ? "RPG" : "rpg_desc"; ViewData["spgSort"] = sortParam == "spg_desc" ? "SPG" : "spg_desc"; ViewData["bpgSort"] = sortParam == "bpg_desc" ? "BPG" : "bpg_desc"; ViewData["toSort"] = sortParam == "to_desc" ? "TO" : "to_desc"; //for paging if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } ViewData["currentFilter"] = searchString; ViewData["posFilter"] = posFilter; IQueryable <Player> players = _playersService.GetPlayers(searchString, posFilter); players = _playersService.SortPLayers(players, sortParam); int pageSize = 20; viewModel.Players = await PaginatedList <Player> .Create(players.AsNoTracking(), pageNumber ?? 1, pageSize); return(View(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)); }