示例#1
0
        public async Task <ProfileEntity> GetProfile(string slug)
        {
            var response = await _repository.Get <ProfileResponse>(slug);

            if (response.StatusCode == 200)
            {
                var profile       = response.Content as ProfileResponse;
                var triviaSection = _triviaFactory.Build(profile.TriviaSection);

                var processedBody = _parser.ParseAll(profile.Body, profile.Title, false);
                processedBody = _markdownWrapper.ConvertToHtml(processedBody);
                processedBody = _alertsInlineTagParser.Parse(processedBody, profile.Alerts);
                processedBody = _inlineQuotesTagParser.Parse(processedBody, profile.InlineQuotes);

                return(new ProfileEntity
                {
                    Title = profile.Title,
                    Slug = profile.Slug,
                    Teaser = profile.Teaser,
                    Quote = profile.Quote,
                    Image = profile.Image,
                    Body = processedBody,
                    Breadcrumbs = profile.Breadcrumbs,
                    Alerts = profile.Alerts,
                    TriviaSubheading = profile.TriviaSubheading,
                    TriviaSection = triviaSection,
                    Subtitle = profile.Subtitle,
                    InlineQuotes = profile.InlineQuotes,
                    EventsBanner = profile.EventsBanner
                });
            }

            return(null);
        }
        public virtual ProcessedShowcase Build(Showcase showcase)
        {
            var body = _tagParserContainer.ParseAll(showcase.Body);

            showcase.Body = _markdownWrapper.ConvertToHtml(body ?? string.Empty);

            var video = showcase.Video;

            if (video != null)
            {
                video.VideoEmbedCode = _tagParserContainer.ParseAll(video.VideoEmbedCode);
            }

            var fields = showcase.FieldOrder;

            if (!fields.Items.Any())
            {
                fields.Items.Add("Primary Items");
                fields.Items.Add("Secondary Items");
                fields.Items.Add("Featured Items");
                fields.Items.Add("News");
                fields.Items.Add("Events");
                fields.Items.Add("Profile");
                fields.Items.Add("Profiles");
                fields.Items.Add("Social Media");
                fields.Items.Add("Body");
                fields.Items.Add("Video");
                fields.Items.Add("Trivia");
            }

            return(new ProcessedShowcase(
                       showcase.Title,
                       showcase.Slug,
                       showcase.Teaser,
                       showcase.MetaDescription,
                       showcase.Subheading,
                       showcase.EventCategory,
                       showcase.EventsCategoryOrTag,
                       showcase.EventSubheading,
                       showcase.NewsSubheading,
                       showcase.NewsCategoryTag,
                       showcase.NewsCategoryOrTag,
                       showcase.BodySubheading,
                       showcase.Body,
                       showcase.NewsArticle,
                       showcase.HeroImageUrl,
                       showcase.SecondaryItems,
                       showcase.Breadcrumbs,
                       showcase.SocialMediaLinksSubheading,
                       showcase.SocialMediaLinks,
                       showcase.Events,
                       showcase.EmailAlertsTopicId,
                       showcase.EmailAlertsText,
                       showcase.Alerts,
                       showcase.PrimaryItems,
                       showcase.FeaturedItemsSubheading,
                       showcase.FeaturedItems,
                       showcase.Profile,
                       showcase.Profiles,
                       showcase.CallToActionBanner,
                       fields,
                       showcase.Icon,
                       showcase.TriviaSubheading,
                       _triviaFactory.Build(showcase.TriviaSection),
                       showcase.ProfileHeading,
                       showcase.ProfileLink,
                       showcase.EventsReadMoreText,
                       video,
                       showcase.TypeformUrl,
                       showcase.SpotlightBanner
                       ));
        }