public PageLinkModel ExtractNextLink() { if (TradingName.IsNullOrEmpty()) throw new ArgumentNullException("TradingName"); Org sibbling = null; var result = new PageLinkModel { Text = TradingName, Title = TradingName, Filename = Filename }; var ints = Authority.Orgs .Where(h => h.HauntedStatus) .OrderBy(o => o.QualifiedLocality) .Select(s => s.Id).ToList(); var nextId = ints.FindNext(Id); if (nextId.HasValue) { sibbling = Authority.Orgs .FirstOrDefault(x => x.Id == nextId.Value); } if (sibbling != null) { result = new PageLinkModel { Text = sibbling.TradingName, Title = sibbling.TradingName, Filename = sibbling.Filename }; } return result; }
public PageLinkModel ExtractNextLink() { if (QualifiedName.IsNullOrEmpty()) throw new ArgumentNullException("QualifiedName"); Authority sibbling = null; // create a default var result = new PageLinkModel { Text = QualifiedName, Title = QualifiedName, Filename = CleanQualifiedName }; if (ParentAuthority != null) { var ints = ParentAuthority.Authoritys .Where(h => h.HasHauntedOrgs && !h.IsCrossBorderArea) .OrderBy(o => o.QualifiedName) .Select(s => s.Id).ToList(); var nextId = ints.FindNext(Id); if (nextId.HasValue) { sibbling = ParentAuthority.Authoritys .FirstOrDefault(x => x.Id == nextId); } } if (sibbling == null) return result; result = new PageLinkModel { Text = sibbling.QualifiedName, Title = sibbling.QualifiedName, Filename = sibbling.CleanQualifiedName }; return result; }
private PageLinkModel CreatePageLinkModel(KeyValuePair<string, int> pathKeyValuePair, ref int index, int rank, IEnumerable<Org> data ) { if (pathKeyValuePair.Key.IsNullOrEmpty()) { throw new Exception( "The key is null or empty; this is usually because the CountryID or AddressTypeID is null or [HauntedOrgs_Fix] has not been run."); } var lineage = new GeoPathModel(pathKeyValuePair.Key); var queryable = data .Where(org => org.HauntedStatus && org.Authority.ParentAuthority.Name == lineage.ParentOfRightmost && org.Authority.QualifiedName == lineage.Rightmost ) .ToList(); var links = queryable .Select(x => x.ExtractLink()) .ToList(); var result = new PageLinkModel(); if (!queryable.Any()) return result; var first = queryable.First(); result = new PageLinkModel { Text = string.Format("{0}. {1}", rank, lineage.FriendlyDescription), Title = string.Format("{0} ({1} pubs in this area)", lineage.FriendlyDescription, pathKeyValuePair.Value), Filename = first.Authority.CleanQualifiedName, Id = index - 1, Links = links }; return result; }
public PageLinkModel ExtractLink() { var info = new PageLinkModel { Id = Id, Text = TradingName, Title = string.Format("{0}, {1}", TradingName, Postcode), Filename = Filename, }; return info; }
public static OutputViewModel CreateRegionOutputViewModel(Authority region, int count, IList<PageLinkModel> authorityLinks, PageLinkModel next, String descriptionPattern) { if (region == null) throw new ArgumentNullException("region"); if (authorityLinks == null) throw new ArgumentNullException("authorityLinks"); if (next == null) throw new ArgumentNullException("next"); var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = region.CleanQualifiedName, Id = region.Id, Text = region.Name, Title = region.Name, Total = region.HauntedPubCount }, }; var pageLinks = authorityLinks.Select(link => link.Text != null ? new PageLinkModel { Text = link.Text, Title = link.Text, Filename = link.Filename, Total = link.Total } : null) .OrderBy(o => o.Text) .ToList(); var articleDescription = string.Format(descriptionPattern, authorityLinks .Select(x => x.Text) .OxfordAnd()); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var model = new OutputViewModel { Filename = region.CleanQualifiedName, PageTitle = region.Name, JumboTitle = region.Name, Action = PageTypeEnum.Region, Total = count, Priority = PageTypePriority.Region, Next = next, Lineage = lineage, PageLinks = pageLinks, MetaDescription = metaDescription, ArticleDescription = articleDescription, Summary = region.Summary, LocalGhostSpecialist = region.IsLocalGhostSpecialistValid ? new PageLinkModel { Text = region.LocalGhostSpecialistName, Title = region.LocalGhostSpecialistName, ExternalUrl = region.LocalGhostSpecialistUrl } : null, LocalGhostHunter = region.IsLocalGhostHuntSpecialistValid ? new PageLinkModel { Text = region.LocalGhostHuntSpecialistName, Title = region.LocalGhostHuntSpecialistName, ExternalUrl = region.LocalGhostHuntSpecialistUrl } : null }; return model; }
public OutputViewModel PrepareLocalityModel( IEnumerable<KeyValuePair<string, PageLinkModel>> orgLocalityLinks, string locality, Authority authority) { if (orgLocalityLinks == null) throw new ArgumentNullException("orgLocalityLinks"); if (locality == null) throw new ArgumentNullException("locality"); if (authority == null) throw new ArgumentNullException("authority"); var collection = new PageLinkKeyedCollection(orgLocalityLinks, locality); if (collection.NextSibling.Key == null) return null; var next = new PageLinkModel { Text = collection.NextSibling.Key, Title = collection.NextSibling.Key, Filename = collection.NextSibling.Key.In(authority.CleanQualifiedName, true), }; var model = OutputViewModel.CreateLocalityOutputViewModel(locality, authority, collection.Links, next, "{0}, {1}, {2}"); return model; }
public static OutputViewModel CreateLocalityOutputViewModel(string locality, Authority authority, IList<PageLinkModel> orgLinks, PageLinkModel next, String descriptionPattern) { if (locality == null) throw new ArgumentNullException("locality"); if (authority == null) throw new ArgumentNullException("authority"); if (orgLinks == null) throw new ArgumentNullException("orgLinks"); if (next == null) throw new ArgumentNullException("next"); var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = authority.ParentAuthority.CleanQualifiedName, Id = authority.ParentAuthority.Id, Text = authority.ParentAuthority.Name, Title = authority.ParentAuthority.Name, Total = authority.ParentAuthority.HauntedPubCount }, Authority = new PageLinkModel { Filename = authority.CleanQualifiedName, Id = authority.Id, Text = authority.Name, Title = authority.Name, Total = authority.HauntedPubCount }, Locality = new PageLinkModel { Filename = locality.In(authority.CleanQualifiedName, true), Id = authority.Id, Text = locality, Title = locality } }; var adjusted = new Breadcrumb(); if (authority.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var articleDescription = string.Format(descriptionPattern, locality, authority.Name, authority.ParentAuthority.Name); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var pageLinks = orgLinks.Select(link => link.Text != null ? new PageLinkModel { Text = link.Text, Title = link.Title, // dpc - example: 10930-the-headless-woman-duddon.html Filename = link.Filename } : null) .OrderBy(o => o.Text) .ToList(); var model = new OutputViewModel { // dpc - example: duddon-in-cheshire-west-and-chester-ua.html Filename = locality.In(authority.CleanQualifiedName, true), JumboTitle = locality.In(authority.QualifiedName), PageTitle = locality.In(authority.QualifiedName), Action = PageTypeEnum.Locality, Total = orgLinks.Count(), Priority = PageTypePriority.Locality, Next = next, Lineage = lineage, MetaDescription = metaDescription, ArticleDescription = articleDescription, PageLinks = pageLinks }; return model; }
public static OutputViewModel CreateOrgOutputViewModel( Org org, PageLinkModel next, String descriptionPattern ) { if (org == null) throw new ArgumentNullException("org"); if (next == null) throw new ArgumentNullException("next"); //var notes = org.Notes.Select(note => new PageLinkModel //{ // Id = note.Id, // Text = note.Text, // Title = note.Text //}).ToList(); const PageTypeEnum action = PageTypeEnum.Pub; var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = org.Authority.ParentAuthority.CleanQualifiedName, Id = org.Id, Text = org.Authority.ParentAuthority.Name, Title = org.Authority.ParentAuthority.Name, Total = org.Authority.ParentAuthority.HauntedPubCount }, Authority = new PageLinkModel { Filename = org.Authority.CleanQualifiedName, Id = org.Id, Text = org.Authority.Name, Title = org.Authority.Name, Total = org.Authority.HauntedPubCount }, Locality = new PageLinkModel { Filename = org.QualifiedLocalityDashified .Clean(), Id = org.Id, Text = org.Locality, Title = org.Locality }, Organisation = new PageLinkModel { Filename = org.Filename, Id = org.Id, Text = org.TradingName, Title = org.TradingName } }; var adjusted = new Breadcrumb(); if (org.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var model = new OutputViewModel { IsMapAvailable = !org.IsOutsideUnitedKingdom, Filename = org.Filename, JumboTitle = org.JumboTitle, PageTitle = org.Title, Action = action, PageLinks = new List<PageLinkModel>(), MetaDescription = org.SeoDescription, Description = org.Description, ArticleDescription = string.Format(descriptionPattern, org.Address, org.PostcodePrimaryPart), Tags = org.Sections, Priority = PageTypePriority.Pub, Next = next, Lat = org.Lat.ToString(), Lon = org.Lon.ToString(), OtherNames = org.Authority.Orgs .Where(o => o.Address == org.Address && o.Postcode == org.Postcode && o.Id != org.Id) .Select( o => new PageLinkModel { Id = o.Id, Text = o.TradingName, Title = o.TradingName, Filename = o.Filename } ).ToList(), Lineage = lineage }; return model; }
public static OutputViewModel CreateAuthorityOutputViewModel(Authority authority, int count, IList<PageLinkModel> locations, PageLinkModel next, string descriptionPattern ) { if (authority == null) throw new ArgumentNullException("authority"); if (locations == null) throw new ArgumentNullException("locations"); if (next == null) throw new ArgumentNullException("next"); var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = authority.ParentAuthority.CleanQualifiedName, Id = authority.ParentAuthority.Id, Text = authority.ParentAuthority.Name, Title = authority.ParentAuthority.Name, Total = authority.ParentAuthority.HauntedPubCount, }, Authority = new PageLinkModel { Filename = authority.CleanQualifiedName, Id = authority.Id, Text = authority.Name, Title = authority.Name, Total = authority.HauntedPubCount, } }; var adjusted = new Breadcrumb(); if (authority.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var pageLinks = locations.OrderBy(x => x.Text).ToList(); var articleDescription = string.Format( descriptionPattern, locations.Select(x => x.Text).OxfordAnd()); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var model = new OutputViewModel { // this is for example: cheshire-west-and-chester-ua.html Filename = authority.CleanQualifiedName, JumboTitle = authority.Name, PageTitle = authority.Name, Action = PageTypeEnum.Authority, Total = count, Priority = PageTypePriority.Authority, Next = next, Lineage = lineage, MetaDescription = metaDescription, ArticleDescription = articleDescription, PageLinks = pageLinks, Summary = authority.Summary, LocalGhostSpecialist = authority.IsLocalGhostSpecialistValid ? new PageLinkModel { Text = authority.LocalGhostSpecialistName, Title = authority.LocalGhostSpecialistName, ExternalUrl = authority.LocalGhostSpecialistUrl } : null, LocalGhostHunter = authority.IsLocalGhostHuntSpecialistValid ? new PageLinkModel { Text = authority.LocalGhostHuntSpecialistName, Title = authority.LocalGhostHuntSpecialistName, ExternalUrl = authority.LocalGhostHuntSpecialistUrl } : null }; return model; }
public static OutputViewModel CreateRegionOutputViewModel(Authority region, int count, IList <PageLinkModel> authorityLinks, PageLinkModel next, String descriptionPattern) { if (region == null) { throw new ArgumentNullException("region"); } if (authorityLinks == null) { throw new ArgumentNullException("authorityLinks"); } if (next == null) { throw new ArgumentNullException("next"); } var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = region.CleanQualifiedName, Id = region.Id, Text = region.Name, Title = region.Name, Total = region.HauntedPubCount }, }; var pageLinks = authorityLinks.Select(link => link.Text != null ? new PageLinkModel { Text = link.Text, Title = link.Text, Filename = link.Filename, Total = link.Total } : null) .OrderBy(o => o.Text) .ToList(); var articleDescription = string.Format(descriptionPattern, authorityLinks .Select(x => x.Text) .OxfordAnd()); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var model = new OutputViewModel { Filename = region.CleanQualifiedName, PageTitle = region.Name, JumboTitle = region.Name, Action = PageTypeEnum.Region, Total = count, Priority = PageTypePriority.Region, Next = next, Lineage = lineage, PageLinks = pageLinks, MetaDescription = metaDescription, ArticleDescription = articleDescription, Summary = region.Summary, LocalGhostSpecialist = region.IsLocalGhostSpecialistValid ? new PageLinkModel { Text = region.LocalGhostSpecialistName, Title = region.LocalGhostSpecialistName, ExternalUrl = region.LocalGhostSpecialistUrl } : null, LocalGhostHunter = region.IsLocalGhostHuntSpecialistValid ? new PageLinkModel { Text = region.LocalGhostHuntSpecialistName, Title = region.LocalGhostHuntSpecialistName, ExternalUrl = region.LocalGhostHuntSpecialistUrl } : null }; return(model); }
public static OutputViewModel CreateOrgOutputViewModel( Org org, PageLinkModel next, String descriptionPattern ) { if (org == null) { throw new ArgumentNullException("org"); } if (next == null) { throw new ArgumentNullException("next"); } //var notes = org.Notes.Select(note => new PageLinkModel //{ // Id = note.Id, // Text = note.Text, // Title = note.Text //}).ToList(); const PageTypeEnum action = PageTypeEnum.Pub; var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = org.Authority.ParentAuthority.CleanQualifiedName, Id = org.Id, Text = org.Authority.ParentAuthority.Name, Title = org.Authority.ParentAuthority.Name, Total = org.Authority.ParentAuthority.HauntedPubCount }, Authority = new PageLinkModel { Filename = org.Authority.CleanQualifiedName, Id = org.Id, Text = org.Authority.Name, Title = org.Authority.Name, Total = org.Authority.HauntedPubCount }, Locality = new PageLinkModel { Filename = org.QualifiedLocalityDashified .Clean(), Id = org.Id, Text = org.Locality, Title = org.Locality }, Organisation = new PageLinkModel { Filename = org.Filename, Id = org.Id, Text = org.TradingName, Title = org.TradingName } }; var adjusted = new Breadcrumb(); if (org.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var model = new OutputViewModel { IsMapAvailable = !org.IsOutsideUnitedKingdom, Filename = org.Filename, JumboTitle = org.JumboTitle, PageTitle = org.Title, Action = action, PageLinks = new List <PageLinkModel>(), MetaDescription = org.SeoDescription, Description = org.Description, ArticleDescription = string.Format(descriptionPattern, org.Address, org.PostcodePrimaryPart), Tags = org.Sections, Priority = PageTypePriority.Pub, Next = next, Lat = org.Lat.ToString(), Lon = org.Lon.ToString(), OtherNames = org.Authority.Orgs .Where(o => o.Address == org.Address && o.Postcode == org.Postcode && o.Id != org.Id) .Select( o => new PageLinkModel { Id = o.Id, Text = o.TradingName, Title = o.TradingName, Filename = o.Filename } ).ToList(), Lineage = lineage }; return(model); }
public static OutputViewModel CreateLocalityOutputViewModel(string locality, Authority authority, IList <PageLinkModel> orgLinks, PageLinkModel next, String descriptionPattern) { if (locality == null) { throw new ArgumentNullException("locality"); } if (authority == null) { throw new ArgumentNullException("authority"); } if (orgLinks == null) { throw new ArgumentNullException("orgLinks"); } if (next == null) { throw new ArgumentNullException("next"); } var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = authority.ParentAuthority.CleanQualifiedName, Id = authority.ParentAuthority.Id, Text = authority.ParentAuthority.Name, Title = authority.ParentAuthority.Name, Total = authority.ParentAuthority.HauntedPubCount }, Authority = new PageLinkModel { Filename = authority.CleanQualifiedName, Id = authority.Id, Text = authority.Name, Title = authority.Name, Total = authority.HauntedPubCount }, Locality = new PageLinkModel { Filename = locality.In(authority.CleanQualifiedName, true), Id = authority.Id, Text = locality, Title = locality } }; var adjusted = new Breadcrumb(); if (authority.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var articleDescription = string.Format(descriptionPattern, locality, authority.Name, authority.ParentAuthority.Name); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var pageLinks = orgLinks.Select(link => link.Text != null ? new PageLinkModel { Text = link.Text, Title = link.Title, // dpc - example: 10930-the-headless-woman-duddon.html Filename = link.Filename } : null) .OrderBy(o => o.Text) .ToList(); var model = new OutputViewModel { // dpc - example: duddon-in-cheshire-west-and-chester-ua.html Filename = locality.In(authority.CleanQualifiedName, true), JumboTitle = locality.In(authority.QualifiedName), PageTitle = locality.In(authority.QualifiedName), Action = PageTypeEnum.Locality, Total = orgLinks.Count(), Priority = PageTypePriority.Locality, Next = next, Lineage = lineage, MetaDescription = metaDescription, ArticleDescription = articleDescription, PageLinks = pageLinks }; return(model); }
public static OutputViewModel CreateAuthorityOutputViewModel(Authority authority, int count, IList <PageLinkModel> locations, PageLinkModel next, string descriptionPattern ) { if (authority == null) { throw new ArgumentNullException("authority"); } if (locations == null) { throw new ArgumentNullException("locations"); } if (next == null) { throw new ArgumentNullException("next"); } var lineage = new Breadcrumb { Region = new PageLinkModel { Filename = authority.ParentAuthority.CleanQualifiedName, Id = authority.ParentAuthority.Id, Text = authority.ParentAuthority.Name, Title = authority.ParentAuthority.Name, Total = authority.ParentAuthority.HauntedPubCount, }, Authority = new PageLinkModel { Filename = authority.CleanQualifiedName, Id = authority.Id, Text = authority.Name, Title = authority.Name, Total = authority.HauntedPubCount, } }; var adjusted = new Breadcrumb(); if (authority.IsOutsideUnitedKingdom) { lineage = adjusted.Swap(lineage); } var pageLinks = locations.OrderBy(x => x.Text).ToList(); var articleDescription = string.Format( descriptionPattern, locations.Select(x => x.Text).OxfordAnd()); var metaDescription = articleDescription .SeoMetaDescriptionTruncate(); var model = new OutputViewModel { // this is for example: cheshire-west-and-chester-ua.html Filename = authority.CleanQualifiedName, JumboTitle = authority.Name, PageTitle = authority.Name, Action = PageTypeEnum.Authority, Total = count, Priority = PageTypePriority.Authority, Next = next, Lineage = lineage, MetaDescription = metaDescription, ArticleDescription = articleDescription, PageLinks = pageLinks, Summary = authority.Summary, LocalGhostSpecialist = authority.IsLocalGhostSpecialistValid ? new PageLinkModel { Text = authority.LocalGhostSpecialistName, Title = authority.LocalGhostSpecialistName, ExternalUrl = authority.LocalGhostSpecialistUrl } : null, LocalGhostHunter = authority.IsLocalGhostHuntSpecialistValid ? new PageLinkModel { Text = authority.LocalGhostHuntSpecialistName, Title = authority.LocalGhostHuntSpecialistName, ExternalUrl = authority.LocalGhostHuntSpecialistUrl } : null }; return(model); }