private void PrepareAllVenues() { var locationJsObject = new StringBuilder("\n"); if (!Venues.Any(v => v.Longitude.HasValue && v.Latitude.HasValue)) { return; } MaxLongitude = Venues.Max(l => l.Longitude)?.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture); MinLongitude = Venues.Min(l => l.Longitude)?.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture); MaxLatitude = Venues.Max(l => l.Latitude)?.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture); MinLatitude = Venues.Min(l => l.Latitude)?.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture); foreach (var venue in Venues) { var teamDescription = new StringBuilder(); var teamsOfVenue = Venues.Where(v => v.VenueId == venue.VenueId).ToList(); foreach (var tov in teamsOfVenue) { teamDescription.AppendFormat("{0} ({1})<br />", tov.TeamName, tov.TeamClubName).Replace("()", string.Empty); // remove () if ClubName is empty } teamDescription.Remove(teamDescription.Length - 6, 6); // remove last <br /> var venueDescription = $"<b>{venue.VenueName}</b><br />{venue.Street}<br />{venue.PostalCode} {venue.City}<br /><br /><b>Team{(teamsOfVenue.Count() > 1 ? "s" : string.Empty)}:</b><br />"; if (venue.Latitude.HasValue && venue.Longitude.HasValue) { var teamsCount = teamsOfVenue.Count; locationJsObject.AppendFormat(_format, venue.Latitude.Value.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture), venue.Longitude.Value.ToString("###.########", System.Globalization.CultureInfo.InvariantCulture), $"{venue.VenueName}, {venue.City} - {teamsCount} Team{(teamsCount > 1 ? "s" : string.Empty)}", venueDescription + teamDescription); } } Locations = locationJsObject.ToString().TrimEnd(new[] { ',', '\n' }); }
public Venue AddVenue(Venue venue) { venue.VenueId = Venues.Any() ? Venues.Max(v => v.VenueId) + 1 : 1; Venues.Add(venue); return(venue); }