public async override Task <ActionResult> Index(ContentModel contentModel) { if (contentModel is null) { throw new ArgumentNullException(nameof(contentModel)); } var team = await _teamDataSource.ReadTeamByRoute(Request.RawUrl, true).ConfigureAwait(false); if (team == null) { return(new HttpNotFoundResult()); } else { var filter = _matchFilterFactory.MatchesForTeams(new List <Guid> { team.TeamId.Value }); var model = new TeamViewModel(contentModel.Content, Services?.UserService) { Team = team, DefaultMatchFilter = filter.filter, Matches = new MatchListingViewModel(contentModel.Content, Services?.UserService) { DateTimeFormatter = _dateFormatter }, }; model.AppliedMatchFilter = _matchFilterQueryStringParser.ParseQueryString(model.DefaultMatchFilter, HttpUtility.ParseQueryString(Request.Url.Query)); model.Matches.Matches = await _matchDataSource.ReadMatchListings(model.AppliedMatchFilter, filter.sortOrder).ConfigureAwait(false); model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.Team); model.IsInACurrentLeague = _createMatchSeasonSelector.SelectPossibleSeasons(model.Team.Seasons, MatchType.LeagueMatch).Any(); model.IsInACurrentKnockoutCompetition = _createMatchSeasonSelector.SelectPossibleSeasons(model.Team.Seasons, MatchType.KnockoutMatch).Any(); var userFilter = _matchFilterHumanizer.MatchingFilter(model.AppliedMatchFilter); if (!string.IsNullOrWhiteSpace(userFilter)) { model.FilterDescription = _matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter) + userFilter; } model.Metadata.PageTitle = $"{_matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter)} for {model.Team.TeamName} stoolball team{userFilter}"; model.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.Teams, Url = new Uri(Constants.Pages.TeamsUrl, UriKind.Relative) }); if (model.Team.Club != null) { model.Breadcrumbs.Add(new Breadcrumb { Name = model.Team.Club.ClubName, Url = new Uri(model.Team.Club.ClubRoute, UriKind.Relative) }); } return(CurrentTemplate(model)); } }
public async override Task <ActionResult> Index(ContentModel contentModel) { if (contentModel is null) { throw new ArgumentNullException(nameof(contentModel)); } var club = await _clubDataSource.ReadClubByRoute(Request.RawUrl).ConfigureAwait(false); if (club == null) { return(new HttpNotFoundResult()); } else { var filter = _matchFilterFactory.MatchesForTeams(club.Teams.Select(team => team.TeamId.Value).ToList()); var model = new ClubViewModel(contentModel.Content, Services?.UserService) { Club = club, DefaultMatchFilter = filter.filter, Matches = new MatchListingViewModel(contentModel.Content, Services?.UserService) { DateTimeFormatter = _dateFormatter } }; model.AppliedMatchFilter = _matchFilterQueryStringParser.ParseQueryString(model.DefaultMatchFilter, HttpUtility.ParseQueryString(Request.Url.Query)); // Only get matches if there are teams, otherwise matches for all teams will be returned if (model.Club.Teams.Count > 0) { model.Matches.Matches = await _matchDataSource.ReadMatchListings(model.AppliedMatchFilter, filter.sortOrder).ConfigureAwait(false); } model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.Club); var userFilter = _matchFilterHumanizer.MatchingFilter(model.AppliedMatchFilter); if (!string.IsNullOrWhiteSpace(userFilter)) { model.FilterDescription = _matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter) + userFilter; } model.Metadata.PageTitle = $"{_matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter)} for {model.Club.ClubName}{userFilter}"; model.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.Teams, Url = new Uri(Constants.Pages.TeamsUrl, UriKind.Relative) }); return(CurrentTemplate(model)); } }
public async override Task <ActionResult> Index(ContentModel contentModel) { if (contentModel is null) { throw new ArgumentNullException(nameof(contentModel)); } var location = await _matchLocationDataSource.ReadMatchLocationByRoute(Request.RawUrl, false).ConfigureAwait(false); if (location == null) { return(new HttpNotFoundResult()); } else { var filter = _matchFilterFactory.MatchesForMatchLocation(location.MatchLocationId.Value); var model = new MatchLocationViewModel(contentModel.Content, Services?.UserService) { MatchLocation = location, DefaultMatchFilter = filter.filter, Matches = new MatchListingViewModel(contentModel.Content, Services?.UserService) { DateTimeFormatter = _dateFormatter }, }; model.AppliedMatchFilter = _matchFilterQueryStringParser.ParseQueryString(model.DefaultMatchFilter, HttpUtility.ParseQueryString(Request.Url.Query)); model.Matches.Matches = await _matchDataSource.ReadMatchListings(model.AppliedMatchFilter, filter.sortOrder).ConfigureAwait(false); model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.MatchLocation); var userFilter = _matchFilterHumanizer.MatchingFilter(model.AppliedMatchFilter); if (!string.IsNullOrWhiteSpace(userFilter)) { model.FilterDescription = _matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter) + userFilter; } model.Metadata.PageTitle = $"{_matchFilterHumanizer.MatchesAndTournaments(model.AppliedMatchFilter)} at {model.MatchLocation.NameAndLocalityOrTownIfDifferent()}{userFilter}"; model.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.MatchLocations, Url = new Uri(Constants.Pages.MatchLocationsUrl, UriKind.Relative) }); return(CurrentTemplate(model)); } }