/// <summary> /// Gets a description of the match suitable for metadata or search results /// </summary> public string Description() { var description = new StringBuilder(PlayerType.Humanize(LetterCasing.Sentence)).Append(" stoolball "); description.Append(MatchType == null ? "tournament" : MatchType.Humanize(LetterCasing.LowerCase)); if (MatchLocation != null) { description.Append(" at ").Append(MatchLocation.NameAndLocalityOrTown()); } description.Append(". "); if (TournamentQualificationType == Matches.TournamentQualificationType.OpenTournament) { description.Append("Any team may enter this tournament. "); } else if (TournamentQualificationType == Matches.TournamentQualificationType.ClosedTournament) { description.Append("This tournament is for invited or qualifying teams only. "); } if (PlayersPerTeam.HasValue) { description.Append(PlayersPerTeam).Append(" players per team. "); } return(description.ToString().TrimEnd()); }
/// <summary> /// Gets a description of the match suitable for metadata or search results /// </summary> public string Description() { var description = new StringBuilder(); // Display match type/season/tournament if (Tournament != null) { // Check for 'the' to get the grammar right var the = (Tournament.TournamentName.StartsWith("THE ", StringComparison.OrdinalIgnoreCase)) ? string.Empty : "the "; description.Append("Match in ").Append(the).Append(Tournament.TournamentName); if (MatchLocation != null) { description.Append(" at ").Append(MatchLocation.NameAndLocalityOrTown()); } description.Append('.'); } else { description.Append("Stoolball ").Append(MatchType.Humanize(LetterCasing.LowerCase)); if (MatchLocation != null) { description.Append(" at ").Append(MatchLocation.NameAndLocalityOrTown()); } if (Season != null) { var the = Season.Competition.CompetitionName.ToUpperInvariant().Contains("THE "); description.Append(" in ").Append(the ? string.Empty : "the ").Append(Season.Competition.CompetitionName); } description.Append('.'); } return(description.ToString()); }
public async Task <ActionResult> UpdateMatchLocation([Bind(Prefix = "MatchLocation", Include = "SecondaryAddressableObjectName,PrimaryAddressableObjectName,StreetDescription,Locality,Town,AdministrativeArea,Postcode,GeoPrecision,Latitude,Longitude")] MatchLocation location) { if (location is null) { throw new System.ArgumentNullException(nameof(location)); } var beforeUpdate = await _matchLocationDataSource.ReadMatchLocationByRoute(Request.RawUrl).ConfigureAwait(false); location.MatchLocationId = beforeUpdate.MatchLocationId; location.MatchLocationRoute = beforeUpdate.MatchLocationRoute; // get this from the unvalidated form instead of via modelbinding so that HTML can be allowed location.MatchLocationNotes = Request.Unvalidated.Form["MatchLocation.MatchLocationNotes"]; var isAuthorized = _authorizationPolicy.IsAuthorized(beforeUpdate); if (isAuthorized[AuthorizedAction.EditMatchLocation] && ModelState.IsValid) { var currentMember = Members.GetCurrentMember(); var updatedMatchLocation = await _matchLocationRepository.UpdateMatchLocation(location, currentMember.Key, currentMember.Name).ConfigureAwait(false); _cacheOverride.OverrideCacheForCurrentMember(CacheConstants.MatchLocationsCacheKeyPrefix); return(Redirect(updatedMatchLocation.MatchLocationRoute + "/edit")); } var viewModel = new MatchLocationViewModel(CurrentPage, Services.UserService) { MatchLocation = location, }; viewModel.IsAuthorized = isAuthorized; viewModel.Metadata.PageTitle = $"Edit {location.NameAndLocalityOrTown()}"; viewModel.Breadcrumbs.Add(new Breadcrumb { Name = Constants.Pages.MatchLocations, Url = new Uri(Constants.Pages.MatchLocationsUrl, UriKind.Relative) }); viewModel.Breadcrumbs.Add(new Breadcrumb { Name = viewModel.MatchLocation.NameAndLocalityOrTownIfDifferent(), Url = new Uri(viewModel.MatchLocation.MatchLocationRoute, UriKind.Relative) }); return(View("EditMatchLocation", viewModel)); }