Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }