Esempio n. 1
0
        /// <summary>
        /// Maps data to an empty view model for a custom entity 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 async Task MapCustomEntityViewModelAsync <TDisplayModel>(
            ICustomEntityPageViewModel <TDisplayModel> viewModel,
            CustomEntityPageViewModelBuilderParameters mappingParameters
            ) where TDisplayModel : ICustomEntityPageDisplayModel
        {
            await MapAsync(viewModel, mappingParameters);

            if (mappingParameters.CustomEntityModel == null)
            {
                throw new ArgumentNullException(nameof(mappingParameters.CustomEntityModel));
            }

            var customEntityRenderDetails = mappingParameters.CustomEntityModel;
            var publishStatusQuery        = mappingParameters.VisualEditorMode.ToPublishStatusQuery();

            var customModel = new CustomEntityRenderDetailsViewModel <TDisplayModel>();

            customModel.CustomEntityId        = customEntityRenderDetails.CustomEntityId;
            customModel.CustomEntityVersionId = customEntityRenderDetails.CustomEntityVersionId;
            customModel.Locale         = customEntityRenderDetails.Locale;
            customModel.Regions        = customEntityRenderDetails.Regions;
            customModel.Title          = customEntityRenderDetails.Title;
            customModel.UrlSlug        = customEntityRenderDetails.UrlSlug;
            customModel.WorkFlowStatus = customEntityRenderDetails.WorkFlowStatus;
            customModel.PublishDate    = customEntityRenderDetails.PublishDate;
            customModel.PublishStatus  = customEntityRenderDetails.PublishStatus;
            customModel.CreateDate     = customEntityRenderDetails.CreateDate;
            customModel.PageUrls       = customEntityRenderDetails.PageUrls;

            customModel.Model = await _customEntityDisplayModelMapper.MapDisplayModelAsync <TDisplayModel>(customEntityRenderDetails, publishStatusQuery);

            viewModel.CustomEntity = customModel;
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <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;
        }