Пример #1
0
        private TViewModel CreateSection <TViewModel>(ScienceIframeSectionBaseSchema schema, string parentSectionHtmlId = null) where TViewModel : ScienceIFrameSectionViewModelBase, new()
        {
            var section = new TViewModel()
            {
                Headline        = schema.Headline,
                PartialViewName = GetPartialViewName(schema),
                HideHeadline    = schema.HideHeadline
            };

            var sectionHtmlId = schema.Headline.ToUrlSegment();

            if (string.IsNullOrWhiteSpace(parentSectionHtmlId))
            {
                section.HtmlId = sectionHtmlId;
            }
            else
            {
                section.HtmlId = string.Join("-", parentSectionHtmlId, sectionHtmlId);
            }


            return(section);
        }
Пример #2
0
        private string GetPartialViewName(ScienceIframeSectionBaseSchema schema)
        {
            switch (schema.DocumentTypeAlias)
            {
            case ScienceIframeSectionRichTextSchema.ModelTypeAlias:
            case ScienceIframeSubSectionRichTextSchema.ModelTypeAlias:
                return(ScienceIFramePartialViewNames.RichText);

            case ScienceIframeSubSectionImageGallerySchema.ModelTypeAlias:
            case ScienceIframeSectionImageGallerySchema.ModelTypeAlias:
                return(ScienceIFramePartialViewNames.ImageGallery);

            case ScienceIframeSectionImageTextSchema.ModelTypeAlias:
            case ScienceIframeSubSectionImageRichTextSchema.ModelTypeAlias:
                return(ScienceIFramePartialViewNames.ImageRichText);

            case ScienceIframeSectionImageCodeSchema.ModelTypeAlias:
            case ScienceIframeSubSectionImageCodeSchema.ModelTypeAlias:
                return(ScienceIFramePartialViewNames.ImageCode);

            default:
                throw new NotSupportedException($"Document Type, {schema.DocumentTypeAlias}, is not currently supported.");
            }
        }