示例#1
0
        private CategorySummary MapCategory(CustomEntityRenderSummary customEntity)
        {
            var model = (CategoryDataModel)customEntity.Model;

            var category = new CategorySummary();

            category.CategoryId       = customEntity.CustomEntityId;
            category.Title            = customEntity.Title;
            category.ShortDescription = model.ShortDescription;

            return(category);
        }
        /// <summary>
        /// We could use AutoMapper here, but to keep it simple let's just do manual mapping
        /// </summary>
        private CategorySummary MapCategory(CustomEntityRenderSummary renderSummary)
        {
            // A CustomEntityRenderSummary will always contain the data model for the custom entity
            var model = renderSummary.Model as CategoryDataModel;

            var category = new CategorySummary();

            category.CategoryId       = renderSummary.CustomEntityId;
            category.Title            = renderSummary.Title;
            category.ShortDescription = model?.ShortDescription;

            return(category);
        }
示例#3
0
        private ICollection <CategorySummary> MapCategories(PagedQueryResult <CustomEntityRenderSummary> customEntityResult)
        {
            var categories = new List <CategorySummary>(customEntityResult.Items.Count());

            foreach (var customEntity in customEntityResult.Items)
            {
                var model = (CategoryDataModel)customEntity.Model;

                var category = new CategorySummary();
                category.CategoryId       = customEntity.CustomEntityId;
                category.Title            = customEntity.Title;
                category.ShortDescription = model.ShortDescription;

                categories.Add(category);
            }

            return(categories);
        }