private async Task <(List <MarketPlaceItems>, int)> GetMarketPlaceItems(int pageSize, int page, string searchedFirstNamePlayer = "", string searchedLastNamePlayer = "") { Func <FutbolPlayer, bool> filterPlayer = null; if (!string.IsNullOrWhiteSpace(searchedFirstNamePlayer) || !string.IsNullOrWhiteSpace(searchedLastNamePlayer)) { filterPlayer = futbolPlayer => futbolPlayer.Name.ToLower().Contains(searchedFirstNamePlayer?.ToLower() ?? " ") || futbolPlayer.LastName.ToLower().Contains(searchedLastNamePlayer?.ToLower() ?? " "); } var skip = (page - 1) * pageSize; var futbolPlayerPaginated = await fantasySoccerService.GetFutbolPlayersStoreAsync(pageSize, skip, filterPlayer); var teams = await fantasySoccerService.GetFutbolTeamsAsync(); var userTeam = await fantasySoccerService.GetUserTeamAsync(); var marketPlaceItems = futbolPlayerPaginated.PaginatedItems.Join(teams, p => p.FutbolTeamID, t => t.ID, (p, t) => new MarketPlaceItems { FutbolPlayer = p, FutbolTeamName = t.Name, UserTeamContainsPlayer = userTeam.Players != null && userTeam.Players.Any(teamPlayer => teamPlayer.ID == p.ID) }).ToList(); return(marketPlaceItems, futbolPlayerPaginated.TotalItems); }
public async Task <IActionResult> Index() { return(View(await fantasySoccerService.GetUserTeamAsync())); }