示例#1
0
        public Payment ToModel(ContentfulPayment entry)
        {
            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert));

            var breadcrumbs = entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            return(new Payment(entry.Title,
                               entry.Slug,
                               entry.Teaser,
                               entry.Description,
                               entry.PaymentDetailsText,
                               entry.ReferenceLabel,
                               entry.ParisReference,
                               entry.Fund,
                               entry.GlCodeCostCentreNumber,
                               entry.Icon,
                               breadcrumbs,
                               entry.ReferenceValidation,
                               entry.MetaDescription,
                               entry.ReturnUrl,
                               entry.CatalogueId,
                               entry.AccountReference,
                               entry.PaymentDescription,
                               alerts
                               ));
        }
示例#2
0
 public ExpandingLinkBox ToModel(ContentfulExpandingLinkBox entry)
 {
     return(new ExpandingLinkBox(entry.Title,
                                 entry.Links.Where(link => ContentfulHelpers.EntryIsNotALink(link.Sys) &&
                                                   _dateComparer.DateNowIsWithinSunriseAndSunsetDates(link.SunriseDate, link.SunsetDate))
                                 .Select(e => _subitemFactory.ToModel(e)).ToList()));
 }
        public DocumentPage ToModel(ContentfulDocumentPage entryContentfulDocumentPage)
        {
            var entry = entryContentfulDocumentPage;

            var breadcrumbs = entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var documents = entry.Documents.Where(section => ContentfulHelpers.EntryIsNotALink(section.SystemProperties))
                            .Select(document => _documentFactory.ToModel(document)).ToList();

            var relatedDocuments = entry.RelatedDocuments.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                                                _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                                   .Select(item => _subitemFactory.ToModel(item)).ToList();

            var updatedAt = entry.Sys.UpdatedAt.Value;

            return(new DocumentPage(
                       title: entry.Title,
                       slug: entry.Slug,
                       teaser: entry.Teaser,
                       metaDescription: entry.MetaDescription,
                       aboutTheDocument: entry.AboutTheDocument,
                       documents: documents,
                       awsDocuments: entry.AwsDocuments,
                       requestAnAccessibleFormatContactInformation: entry.RequestAnAccessibleFormatContactInformation,
                       furtherInformation: entry.FurtherInformation,
                       relatedDocuments: relatedDocuments,
                       datePublished: entry.DatePublished,
                       lastUpdated: entry.LastUpdated,
                       breadcrumbs: breadcrumbs,
                       updatedAt: updatedAt));
        }
示例#4
0
        public Event ToModel(ContentfulEvent entry)
        {
            var eventDocuments =
                entry.Documents.Where(document => ContentfulHelpers.EntryIsNotALink(document.SystemProperties))
                .Select(document => _documentFactory.ToModel(document)).ToList();

            var imageUrl = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                ? entry.Image?.File?.Url
                : string.Empty;

            var group = _groupFactory.ToModel(entry.Group);

            var categories = entry.EventCategories.Select(ec => _eventCategoryFactory.ToModel(ec));

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys)
                                            &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(
                                                alert.SunriseDate, alert.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            return(new Event(entry.Title, entry.Slug, entry.Teaser, imageUrl, entry.Description, entry.Fee,
                             entry.Location,
                             entry.SubmittedBy, entry.EventDate, entry.StartTime, entry.EndTime, entry.Occurences, entry.Frequency,
                             new List <Crumb> {
                new Crumb("Events", string.Empty, "events")
            },
                             ImageConverter.ConvertToThumbnail(imageUrl), eventDocuments, entry.Categories, entry.MapPosition,
                             entry.Featured, entry.BookingInformation, entry.Sys.UpdatedAt, entry.Tags, group, alerts, categories.ToList(), entry.Free, entry.Paid, entry.AccessibleTransportLink, entry.MetaDescription));
        }
示例#5
0
        public GroupHomepage ToModel(ContentfulGroupHomepage entry)
        {
            var backgroundImage = ContentfulHelpers.EntryIsNotALink(entry.BackgroundImage.SystemProperties)
                                           ? entry.BackgroundImage.File.Url : string.Empty;


            var groups = entry.FeaturedGroups.Select(g => _groupFactory.ToModel(g));

            var groupCategory = _groupCategoryListFactory.ToModel(entry.FeaturedGroupsCategory);

            var groupSubCategory = _groupSubCategoryListFactory.ToModel(entry.FeaturedGroupsSubCategory);

            var featuredGroup = groups.Where(group => _dateComparer.DateNowIsNotBetweenHiddenRange(
                                                 group.DateHiddenFrom, group.DateHiddenTo)).ToList();

            var alerts = entry.Alerts.Select(_ => _alertFactory.ToModel(_));

            var bodyHeading = entry.BodyHeading;

            var body = entry.Body;

            var secondaryBodyHeading = entry.SecondaryBodyHeading;

            var secondaryBody = entry.SecondaryBody;

            var eventBanner = ContentfulHelpers.EntryIsNotALink(entry.EventBanner.Sys)
                ? _eventBannerFactory.ToModel(entry.EventBanner) : new NullEventBanner();

            return(new GroupHomepage(entry.Title, entry.Slug, entry.MetaDescription, backgroundImage, entry.FeaturedGroupsHeading, featuredGroup, groupCategory, groupSubCategory, alerts, bodyHeading, body, secondaryBodyHeading, secondaryBody, eventBanner));
        }
        public Newsroom ToModel(ContentfulNewsRoom entry)
        {
            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert));

            return(new Newsroom(alerts.ToList(), entry.EmailAlerts, entry.EmailAlertsTopicId));
        }
示例#7
0
        public Organisation ToModel(ContentfulOrganisation entry)
        {
            var imageUrl = entry.Image != null
                ? ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                    ? entry.Image.File.Url
                    : string.Empty
                : string.Empty;

            return(new Organisation(entry.Title, entry.Slug, imageUrl, entry.AboutUs, entry.Phone, entry.Email,
                                    entry.Volunteering, entry.VolunteeringText, entry.Donations, entry.DonationsText, entry.DonationsUrl));
        }
        public CarouselContent ToModel(ContentfulCarouselContent carousel)
        {
            var title  = carousel.Title ?? string.Empty;
            var slug   = carousel.Slug ?? string.Empty;
            var teaser = carousel.Teaser ?? string.Empty;
            var image  = ContentfulHelpers.EntryIsNotALink(carousel.Image.SystemProperties) ? carousel.Image.File.Url : string.Empty;

            var url = carousel.Url ?? string.Empty;

            DateTime sunriseDate = DateComparer.DateFieldToDate(carousel.SunriseDate);
            DateTime sunsetDate  = DateComparer.DateFieldToDate(carousel.SunsetDate);

            return(new CarouselContent(title, slug, teaser, image, sunriseDate, sunsetDate, url));
        }
        public Section ToModel(ContentfulSection entry)
        {
            var profiles = entry.Profiles.Where(profile => ContentfulHelpers.EntryIsNotALink(profile.Sys))
                           .Select(profile => _profileFactory.ToModel(profile)).ToList();
            var documents = entry.Documents.Where(document => ContentfulHelpers.EntryIsNotALink(document.SystemProperties))
                            .Select(document => _documentFactory.ToModel(document)).ToList();
            var body = _videoRepository.Process(entry.Body);

            var alertsInline = entry.AlertsInline.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                                        _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                               .Select(alertInline => _alertFactory.ToModel(alertInline));

            return(new Section(entry.Title, entry.Slug, entry.MetaDescription, body, profiles, documents,
                               entry.SunriseDate, entry.SunsetDate, alertsInline));
        }
示例#10
0
        public Article ToModel(ContentfulArticle entryContentfulArticle)
        {
            var entry = entryContentfulArticle;

            var sections = entry.Sections.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) && _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                           .Select(section => _sectionFactory.ToModel(section)).ToList();

            var breadcrumbs = entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var profiles = entry.Profiles.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                           .Select(profile => _profileFactory.ToModel(profile)).ToList();

            var topic = _parentTopicFactory.ToModel(entryContentfulArticle) ?? new NullTopic();

            var documents = entry.Documents.Where(section => ContentfulHelpers.EntryIsNotALink(section.SystemProperties))
                            .Select(document => _documentFactory.ToModel(document)).ToList();

            var body = !string.IsNullOrEmpty(entry.Body) ? _videoRepository.Process(entry.Body) : string.Empty;

            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert));

            var alertsInline = entry.AlertsInline.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                                        _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                               .Select(alertInline => _alertFactory.ToModel(alertInline));

            var backgroundImage = ContentfulHelpers.EntryIsNotALink(entry.BackgroundImage.SystemProperties)
                                        ? entry.BackgroundImage.File.Url : string.Empty;

            var image = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                                        ? entry.Image.File.Url : string.Empty;

            var sectionUpdatedAt = entry.Sections
                                   .Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) && _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                                   .Where(section => section.Sys.UpdatedAt is not null)
                                   .Select(section => section.Sys.UpdatedAt.Value)
                                   .OrderByDescending(section => section)
                                   .FirstOrDefault();

            var updatedAt = sectionUpdatedAt > entry.Sys.UpdatedAt.Value ? sectionUpdatedAt : entry.Sys.UpdatedAt.Value;

            var hideLastUpdated = entry.HideLastUpdated;

            return(new Article(body, entry.Slug, entry.Title, entry.Teaser, entry.MetaDescription, entry.Icon, backgroundImage, image,
                               sections, breadcrumbs, alerts, profiles, topic, documents, entry.SunriseDate, entry.SunsetDate, alertsInline, updatedAt, hideLastUpdated));
        }
示例#11
0
        public News ToModel(ContentfulNews entry)
        {
            var documents = entry.Documents.Where(document => ContentfulHelpers.EntryIsNotALink(document.SystemProperties))
                            .Select(document => _documentFactory.ToModel(document)).ToList();
            var imageUrl = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties) ? entry.Image.File.Url : string.Empty;

            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert));

            return(new News(entry.Title, entry.Slug, entry.Teaser, entry.Purpose, imageUrl, ImageConverter.ConvertToThumbnail(imageUrl),
                            _videoRepository.Process(entry.Body), entry.SunriseDate, entry.SunsetDate, new List <Crumb> {
                new Crumb("News", string.Empty, "news")
            },
                            alerts.ToList(), entry.Tags, documents, entry.Categories));
        }
        public Group ToModel(ContentfulGroup entry)
        {
            var imageUrl = entry.Image != null
                ? ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                    ? entry.Image.File.Url
                    : string.Empty
                : string.Empty;

            var categoriesReferences = entry.CategoriesReference != null
                ? entry.CategoriesReference.Where(o => o != null).Select(catogory => _contentfulGroupCategoryFactory.ToModel(catogory)).ToList()
                : new List <GroupCategory>();

            var subCategories = entry.SubCategories != null
                ? entry.SubCategories.Where(o => o != null).Select(category => _contentfulGroupSubCategoryFactory.ToModel(category)).ToList()
                : new List <GroupSubCategory>();

            var groupDocuments = entry.AdditionalDocuments.Where(document => ContentfulHelpers.EntryIsNotALink(document.SystemProperties)).Select(document => _documentFactory.ToModel(document)).ToList();

            var organisation = entry.Organisation != null?_contentfulOrganisationFactory.ToModel(entry.Organisation) : new Organisation();

            var status = "Published";

            if (!_dateComparer.DateNowIsNotBetweenHiddenRange(entry.DateHiddenFrom, entry.DateHiddenTo))
            {
                status = "Archived";
            }

            var administrators = entry.GroupAdministrators;

            var cost = entry.Cost != null && entry.Cost.Any() ? entry.Cost : new List <string>();

            var groupBranding = entry.GroupBranding != null?entry.GroupBranding.Where(o => o != null).Select(branding => _contentfulGroupBrandingFactory.ToModel(branding)).ToList() : new List <GroupBranding>();

            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert));

            return(new Group(entry.Name, entry.Slug, entry.MetaDescription, entry.PhoneNumber, entry.Email, entry.Website,
                             entry.Twitter, entry.Facebook, entry.Address, entry.Description, imageUrl, ImageConverter.ConvertToThumbnail(imageUrl),
                             categoriesReferences, subCategories, new List <Crumb> {
                new Crumb("Stockport Local", string.Empty, "groups")
            }, entry.MapPosition, entry.Volunteering,
                             administrators, entry.DateHiddenFrom, entry.DateHiddenTo, status, cost, entry.CostText, entry.AbilityLevel, entry.VolunteeringText,
                             organisation, entry.Donations, entry.AccessibleTransportLink, groupBranding, entry.Tags, entry.AdditionalInformation, groupDocuments, entry.Sys.UpdatedAt, entry.SuitableFor, entry.AgeRange, entry.DonationsText, entry.DonationsUrl, alerts));
        }
示例#13
0
        public StartPage ToModel(ContentfulStartPage entry)
        {
            var alerts = entry.Alerts.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var breadcrumbs =
                entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var alertsInline = entry.AlertsInline.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys) &&
                                                        _dateComparer.DateNowIsWithinSunriseAndSunsetDates(section.SunriseDate, section.SunsetDate))
                               .Select(alertInline => _alertFactory.ToModel(alertInline));

            return(new StartPage(entry.Title, entry.Slug, entry.Teaser, entry.Summary, entry.UpperBody,
                                 entry.FormLinkLabel, entry.FormLink, entry.LowerBody, entry.BackgroundImage, entry.Icon,
                                 breadcrumbs, alerts, alertsInline, entry.SunriseDate, entry.SunsetDate));
        }
        public Topic ToModel(ContentfulTopic entry)
        {
            var subItems = entry.SubItems.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                                _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                           .Select(subItem => _subItemFactory.ToModel(subItem)).ToList();

            var secondaryItems = entry.SecondaryItems.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                                 .Select(subItem => _subItemFactory.ToModel(subItem)).ToList();

            var tertiaryItems = entry.TertiaryItems.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                                          _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                                .Select(subItem => _subItemFactory.ToModel(subItem)).ToList();

            var breadcrumbs = entry.Breadcrumbs.Where(crumb => ContentfulHelpers.EntryIsNotALink(crumb.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(alert.SunriseDate, alert.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var backgroundImage = ContentfulHelpers.EntryIsNotALink(entry.BackgroundImage.SystemProperties)
                                        ? entry.BackgroundImage.File.Url : string.Empty;

            var image = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                                        ? entry.Image.File.Url : string.Empty;

            var eventBanner = ContentfulHelpers.EntryIsNotALink(entry.EventBanner.Sys)
                                ? _eventBannerFactory.ToModel(entry.EventBanner) : new NullEventBanner();

            var expandingLinkBoxes =
                entry.ExpandingLinkBoxes.Where(e => ContentfulHelpers.EntryIsNotALink(e.Sys))
                .Select(e => _expandingLinkBoxFactory.ToModel(e)).ToList();

            var primaryItemTitle = entry.PrimaryItemTitle;

            var displayContactUs = entry.DisplayContactUs;

            return(new Topic(entry.Slug, entry.Name, entry.Teaser, entry.MetaDescription, entry.Summary, entry.Icon, backgroundImage, image,
                             subItems, secondaryItems, tertiaryItems, breadcrumbs, alerts, entry.SunriseDate, entry.SunsetDate,
                             entry.EmailAlerts, entry.EmailAlertsTopicId, eventBanner, entry.ExpandingLinkTitle,
                             expandingLinkBoxes, primaryItemTitle, displayContactUs));
        }
示例#15
0
        public GroupCategory ToModel(ContentfulGroupCategory entry)
        {
            var name = !string.IsNullOrEmpty(entry.Name)
                ? entry.Name
                : "";

            var slug = !string.IsNullOrEmpty(entry.Slug)
                ? entry.Slug
                : "";

            var icon = !string.IsNullOrEmpty(entry.Icon)
                ? entry.Icon
                : "";

            var image = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties)
                ? entry.Image.File.Url
                : string.Empty;

            return(new GroupCategory(name, slug, icon, image));
        }
        public ContactUsArea ToModel(ContentfulContactUsArea entry)
        {
            var title = !string.IsNullOrEmpty(entry.Title)
                ? entry.Title
                : "";

            var slug = !string.IsNullOrEmpty(entry.Slug)
                ? entry.Slug
                : "";

            var categoriesTitle = !string.IsNullOrEmpty(entry.CategoriesTitle)
                ? entry.CategoriesTitle
                : "";

            var insetTextTitle = !string.IsNullOrEmpty(entry.InsetTextTitle)
                ? entry.InsetTextTitle
                : "";

            var insetTextBody = !string.IsNullOrEmpty(entry.InsetTextBody)
                ? entry.InsetTextBody
                : "";

            var breadcrumbs =
                entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var primaryItems =
                entry.PrimaryItems.Where(primItem => ContentfulHelpers.EntryIsNotALink(primItem.Sys) &&
                                         _dateComparer.DateNowIsWithinSunriseAndSunsetDates(primItem.SunriseDate, primItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(alert.SunriseDate, alert.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var contactUsCategories =
                entry.ContactUsCategories.Where(contactUsCategory => ContentfulHelpers.EntryIsNotALink(contactUsCategory.Sys))
                .Select(contactUsCategory => _contactUsCategoryFactory.ToModel(contactUsCategory)).ToList();

            return(new ContactUsArea(slug, title, categoriesTitle, breadcrumbs, alerts, primaryItems, contactUsCategories, insetTextTitle, insetTextBody, entry.MetaDescription));
        }
        public PrivacyNotice ToModel(ContentfulPrivacyNotice entry)
        {
            var breadcrumbs = new List <Crumb>();

            try
            {
                breadcrumbs = entry.Breadcrumbs
                              .Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Could not get breadcrumbs for Privacy Notice: {ex.Message}");
            }

            var topic = _parentTopicFactory.ToModel(entry) ?? new NullTopic();

            var privacyNotice = new PrivacyNotice(entry.Slug, entry.Title, entry.Category, entry.OutsideEu, entry.AutomatedDecision, entry.Purpose, entry.TypeOfData, entry.Legislation, entry.Obtained, entry.ExternallyShared, entry.RetentionPeriod, entry.UrlOne, entry.UrlTwo, entry.UrlThree, breadcrumbs, topic);

            return(privacyNotice);
        }
        public Profile ToModel(ContentfulProfile entry)
        {
            var breadcrumbs = entry.Breadcrumbs.Where(crumb => ContentfulHelpers.EntryIsNotALink(crumb.Sys))
                              .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var imageUrl = ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties) ? entry.Image.File.Url : string.Empty;

            var triviaSubheading = !string.IsNullOrEmpty(entry.TriviaSubheading)
                ? entry.TriviaSubheading
                : "";

            var triviaSection = entry.TriviaSection.Where(fact => ContentfulHelpers.EntryIsNotALink(fact.Sys))
                                .Select(fact => _triviaFactory.ToModel(fact)).ToList();

            var inlineQuotes = entry.InlineQuotes.Select(quote => _inlineQuoteContentfulFactory.ToModel(quote)).ToList();

            var eventsBanner = _eventBannerFactory.ToModel(entry.EventsBanner);

            return(new Profile
            {
                Alerts = alerts,
                Author = entry.Author,
                Body = entry.Body,
                Breadcrumbs = breadcrumbs,
                Image = imageUrl,
                InlineQuotes = inlineQuotes,
                Quote = entry.Quote,
                Slug = entry.Slug,
                Subject = entry.Subject,
                Subtitle = entry.Subtitle,
                Title = entry.Title,
                TriviaSection = triviaSection,
                TriviaSubheading = triviaSubheading,
                EventsBanner = eventsBanner
            });
        }
示例#19
0
        public Homepage ToModel(ContentfulHomepage entry)
        {
            var featuredTasksHeading = !string.IsNullOrEmpty(entry.FeaturedTasksHeading) ? entry.FeaturedTasksHeading : string.Empty;
            var featuredTasksSummary = !string.IsNullOrEmpty(entry.FeaturedTasksSummary) ? entry.FeaturedTasksSummary : string.Empty;
            var backgroundImage      = !string.IsNullOrEmpty(entry.BackgroundImage.File?.Url) ? entry.BackgroundImage.File.Url : string.Empty;
            var freeText             = !string.IsNullOrEmpty(entry.FreeText) ? entry.FreeText : string.Empty;

            var popularSearchTerms = ContentfulHelpers.ConvertToListOfStrings(entry.PopularSearchTerms);

            var featuredTasks =
                entry.FeaturedTasks.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                          _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var featuredTopics =
                entry.FeaturedTopics.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                           _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(alert.SunriseDate, alert.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var carouselContents =
                entry.CarouselContents.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                             _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                .Select(item => _carouselFactory.ToModel(item)).ToList();

            var campaignBanner = _carouselFactory.ToModel(entry.CampaignBanner);

            var featuredGroup = entry.FeaturedGroups.Where(group => ContentfulHelpers.EntryIsNotALink(group.Sys) &&
                                                           _dateComparer.DateNowIsNotBetweenHiddenRange(
                                                               group.DateHiddenFrom, group.DateHiddenTo))
                                .Select(group => _groupFactory.ToModel(group)).FirstOrDefault();

            return(new Homepage(popularSearchTerms, featuredTasksHeading, featuredTasksSummary, featuredTasks,
                                featuredTopics, alerts, carouselContents, backgroundImage, freeText, featuredGroup, entry.EventCategory, entry.MetaDescription, campaignBanner));
        }
示例#20
0
        public Footer ToModel(ContentfulFooter entry)
        {
            var title = !string.IsNullOrEmpty(entry.Title)
                ? entry.Title
                : "";

            var slug = !string.IsNullOrEmpty(entry.Slug)
                ? entry.Slug
                : "";

            var copyrightSection = !string.IsNullOrEmpty(entry.CopyrightSection)
                ? entry.CopyrightSection
                : "";

            var links =
                entry.Links.Where(link => ContentfulHelpers.EntryIsNotALink(link.Sys))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var socialMediaLinks = entry.SocialMediaLinks.Where(media => ContentfulHelpers.EntryIsNotALink(media.Sys))
                                   .Select(media => _socialMediaFactory.ToModel(media)).ToList();

            return(new Footer(title, slug, links, socialMediaLinks));
        }
 private bool EntryIsValid(ContentfulReference entry)
 {
     return(ContentfulHelpers.EntryIsNotALink(entry.Sys) && _dateComparer.DateNowIsWithinSunriseAndSunsetDates(entry.SunriseDate, entry.SunsetDate));
 }
 private string GetEntryImage(ContentfulReference entry)
 {
     return(ContentfulHelpers.EntryIsNotALink(entry.Image.SystemProperties) ? entry.Image.File.Url : string.Empty);
 }
        public Showcase ToModel(ContentfulShowcase entry)
        {
            var heroImage = ContentfulHelpers.EntryIsNotALink(entry.HeroImage.SystemProperties)
                ? entry.HeroImage.File.Url
                : string.Empty;

            var primaryItems =
                entry.PrimaryItems.Where(primItem => ContentfulHelpers.EntryIsNotALink(primItem.Sys) &&
                                         _dateComparer.DateNowIsWithinSunriseAndSunsetDates(primItem.SunriseDate, primItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var secondaryItems =
                entry.SecondaryItems.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                           _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var featuredItems =
                entry.FeaturedItems.Where(featItem => ContentfulHelpers.EntryIsNotALink(featItem.Sys) &&
                                          _dateComparer.DateNowIsWithinSunriseAndSunsetDates(featItem.SunriseDate, featItem.SunsetDate))
                .Select(item => _subitemFactory.ToModel(item)).ToList();

            var socialMediaLinks = entry.SocialMediaLinks.Where(media => ContentfulHelpers.EntryIsNotALink(media.Sys))
                                   .Select(media => _socialMediaFactory.ToModel(media)).ToList();

            var breadcrumbs =
                entry.Breadcrumbs.Where(section => ContentfulHelpers.EntryIsNotALink(section.Sys))
                .Select(crumb => _crumbFactory.ToModel(crumb)).ToList();

            var profile = entry.Profile != null
                ? _profileFactory.ToModel(entry.Profile)
                : null;

            var profiles = entry.Profiles.Where(singleProfile => ContentfulHelpers.EntryIsNotALink(singleProfile.Sys))
                           .Select(singleProfile => _profileFactory.ToModel(singleProfile)).ToList();

            var alerts = entry.Alerts.Where(alert => ContentfulHelpers.EntryIsNotALink(alert.Sys) &&
                                            _dateComparer.DateNowIsWithinSunriseAndSunsetDates(alert.SunriseDate, alert.SunsetDate))
                         .Select(alert => _alertFactory.ToModel(alert)).ToList();

            var tertiaryItems = entry.TertiaryItems.Where(subItem => ContentfulHelpers.EntryIsNotALink(subItem.Sys) &&
                                                          _dateComparer.DateNowIsWithinSunriseAndSunsetDates(subItem.SunriseDate, subItem.SunsetDate))
                                .Select(subItem => _subitemFactory.ToModel(subItem)).ToList();

            var triviaSection = entry.TriviaSection.Where(fact => ContentfulHelpers.EntryIsNotALink(fact.Sys))
                                .Select(fact => _triviaFactory.ToModel(fact)).ToList();

            var callToActionBanner = entry.CallToActionBanner != null
                ? _callToActionBannerContentfulFactory.ToModel(entry.CallToActionBanner)
                : null;

            var video = entry.Video != null
                ? _videoFactory.ToModel(entry.Video)
                : null;

            var spotlightBanner = entry.SpotlightBanner != null
                ? _spotlightBannerFactory.ToModel(entry.SpotlightBanner)
                : null;

            return(new Showcase
            {
                Title = entry.Title,
                Slug = entry.Slug,
                HeroImageUrl = heroImage,
                PrimaryItems = primaryItems,
                Teaser = entry.Teaser,
                MetaDescription = entry.MetaDescription,
                Subheading = entry.Subheading,
                SecondaryItems = secondaryItems,
                FeaturedItemsSubheading = entry.FeaturedItemsSubheading,
                FeaturedItems = featuredItems,
                SocialMediaLinksSubheading = entry.SocialMediaLinksSubheading,
                SocialMediaLinks = socialMediaLinks,
                EventSubheading = entry.EventSubheading,
                EventCategory = entry.EventCategory,
                EventsReadMoreText = entry.EventsReadMoreText,
                NewsSubheading = entry.NewsSubheading,
                NewsCategoryTag = entry.NewsCategoryTag,
                Breadcrumbs = breadcrumbs,
                BodySubheading = entry.BodySubheading,
                Body = entry.Body,
                Profile = profile,
                ProfileHeading = entry.ProfileHeading,
                ProfileLink = entry.ProfileLink,
                Profiles = profiles,
                FieldOrder = entry.FieldOrder,
                EmailAlertsTopicId = entry.EmailAlertsTopicId,
                EmailAlertsText = entry.EmailAlertsText,
                Alerts = alerts,
                Icon = entry.Icon,
                TertiaryItems = tertiaryItems,
                TriviaSubheading = entry.TriviaSubheading,
                TriviaSection = triviaSection,
                CallToActionBanner = callToActionBanner,
                Video = video,
                TypeformUrl = entry.TypeformUrl,
                SpotlightBanner = spotlightBanner
            });
        }