コード例 #1
0
        private string GetPartialViewName(ScienceCategorySectionBaseSchema schema)
        {
            switch (schema.DocumentTypeAlias)
            {
            case ScienceCategorySectionRichTextSchema.ModelTypeAlias:
            case ScienceCategorySubSectionRichTextSchema.ModelTypeAlias:
                return(ScienceCategoryPartialViewNames.RichText);

            case ScienceCategorySubSectionImageGallerySchema.ModelTypeAlias:
            case ScienceCategorySectionImageGallerySchema.ModelTypeAlias:
                return(ScienceCategoryPartialViewNames.ImageGallery);

            case ScienceCategoryIndividualSectionImageTextSchema.ModelTypeAlias:
            case ScienceCategorySectionImageTextSchema.ModelTypeAlias:
            case ScienceCategorySubSectionImageRichTextSchema.ModelTypeAlias:
                return(ScienceCategoryPartialViewNames.ImageRichText);

            case ScienceCategoryIndividualSectionImageCodeSchema.ModelTypeAlias:
            case ScienceCategorySectionImageCodeSchema.ModelTypeAlias:
            case ScienceCategorySubSectionImageCodeSchema.ModelTypeAlias:
                return(ScienceCategoryPartialViewNames.ImageCode);

            case ScienceCategorySectionSliderSchema.ModelTypeAlias:
            case ScienceCategorySubSectionSliderSchema.ModelTypeAlias:
                return(ScienceCategoryPartialViewNames.Slider);

            default:
                throw new NotSupportedException($"Document Type, {schema.DocumentTypeAlias}, is not currently supported.");
            }
        }
コード例 #2
0
        private TViewModel CreateSection <TViewModel>(ScienceCategorySectionBaseSchema schema, string parentSectionHtmlId = null) where TViewModel : ScienceCategorySectionViewModelBase, 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);
        }