Exemple #1
0
        private CustomEntityDetailsPageViewModel <TDisplayModel> MapCustomEntityModel <TDisplayModel>(
            PageRenderDetails page,
            CustomEntityRenderDetails customEntityRenderDetails,
            VisualEditorMode siteViewerMode
            ) where TDisplayModel : ICustomEntityDetailsDisplayViewModel
        {
            var vm = Map <CustomEntityDetailsPageViewModel <TDisplayModel> >(page, siteViewerMode);

            var customModel = new CustomEntityRenderDetailsViewModel <TDisplayModel>();

            customModel.CustomEntityId        = customEntityRenderDetails.CustomEntityId;
            customModel.CustomEntityVersionId = customEntityRenderDetails.CustomEntityVersionId;
            customModel.Locale         = customEntityRenderDetails.Locale;
            customModel.Sections       = customEntityRenderDetails.Sections;
            customModel.Title          = customEntityRenderDetails.Title;
            customModel.UrlSlug        = customEntityRenderDetails.UrlSlug;
            customModel.WorkFlowStatus = customEntityRenderDetails.WorkFlowStatus;
            customModel.Model          = _customEntityDisplayModelMapper.MapDetails <TDisplayModel>(customEntityRenderDetails);

            vm.CustomEntity = customModel;

            return(vm);
        }
        /// <summary>
        /// Maps data to an empty view model for a custom entity details page.
        /// </summary>
        /// <param name="displayModelType">The type information of the display model to apply to the generic view model.</param>
        /// <param name="viewModel">The view model to map data to.</param>
        /// <param name="mappingParameters">The data passed through to map to the view model.</param>
        public virtual void MapCustomEntityViewModel <TDisplayModel>(
            ICustomEntityDetailsPageViewModel <TDisplayModel> viewModel,
            CustomEntityDetailsPageViewModelBuilderParameters mappingParameters
            ) where TDisplayModel : ICustomEntityDetailsDisplayViewModel
        {
            Map(viewModel, mappingParameters);

            Condition.Requires(mappingParameters.CustomEntityModel).IsNotNull();

            var customEntityRenderDetails = mappingParameters.CustomEntityModel;

            var customModel = new CustomEntityRenderDetailsViewModel <TDisplayModel>();

            customModel.CustomEntityId        = customEntityRenderDetails.CustomEntityId;
            customModel.CustomEntityVersionId = customEntityRenderDetails.CustomEntityVersionId;
            customModel.Locale         = customEntityRenderDetails.Locale;
            customModel.Sections       = customEntityRenderDetails.Sections;
            customModel.Title          = customEntityRenderDetails.Title;
            customModel.UrlSlug        = customEntityRenderDetails.UrlSlug;
            customModel.WorkFlowStatus = customEntityRenderDetails.WorkFlowStatus;
            customModel.Model          = _customEntityDisplayModelMapper.MapDetails <TDisplayModel>(customEntityRenderDetails);

            viewModel.CustomEntity = customModel;
        }