public async override Task <ActionResult> Index(ContentModel contentModel) { if (contentModel is null) { throw new System.ArgumentNullException(nameof(contentModel)); } var model = new TournamentViewModel(contentModel.Content, Services?.UserService) { Tournament = await _tournamentDataSource.ReadTournamentByRoute(Request.RawUrl).ConfigureAwait(false), DateTimeFormatter = _dateFormatter }; if (model.Tournament == null) { return(new HttpNotFoundResult()); } else { model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.Tournament); model.Metadata.PageTitle = model.Tournament.TournamentFullNameAndPlayerType(x => _dateFormatter.FormatDate(x, false, false, false)); model.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.Tournaments, Url = new Uri(Constants.Pages.TournamentsUrl, UriKind.Relative) }); model.Breadcrumbs.Add(new Breadcrumb { Name = model.Tournament.TournamentName, Url = new Uri(model.Tournament.TournamentRoute, UriKind.Relative) }); return(CurrentTemplate(model)); } }
public async override Task <ActionResult> Index(ContentModel contentModel) { if (contentModel is null) { throw new ArgumentNullException(nameof(contentModel)); } var model = new TournamentViewModel(contentModel.Content, Services?.UserService) { Tournament = await _tournamentDataSource.ReadTournamentByRoute(Request.Url.AbsolutePath).ConfigureAwait(false), DateTimeFormatter = _dateFormatter }; if (model.Tournament == null) { return(new HttpNotFoundResult()); } else { model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.Tournament); model.Tournament.Comments = await _commentsDataSource.ReadComments(model.Tournament.TournamentId.Value).ConfigureAwait(false); foreach (var comment in model.Tournament.Comments) { comment.Comment = _emailProtector.ProtectEmailAddresses(comment.Comment, User.Identity.IsAuthenticated); comment.Comment = _badLanguageFilter.Filter(comment.Comment); } var filter = _matchFilterFactory.MatchesForTournament(model.Tournament.TournamentId.Value); model.Matches = new MatchListingViewModel(contentModel.Content, Services?.UserService) { Matches = await _matchDataSource.ReadMatchListings(filter.filter, filter.sortOrder).ConfigureAwait(false), ShowMatchDate = false, HighlightNextMatch = false, DateTimeFormatter = _dateFormatter }; model.Metadata.PageTitle = model.Tournament.TournamentFullNameAndPlayerType(x => _dateFormatter.FormatDate(x, false, false, false)); model.Metadata.Description = model.Tournament.Description(); model.Tournament.TournamentNotes = _emailProtector.ProtectEmailAddresses(model.Tournament.TournamentNotes, User.Identity.IsAuthenticated); model.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.Tournaments, Url = new Uri(Constants.Pages.TournamentsUrl, UriKind.Relative) }); return(CurrentTemplate(model)); } }