示例#1
0
        public void OnGet(int parentId, string guid)
        {
            var content = new Content {
                ContentTypeGuid = guid
            };

            var modelType = _typeMappings.GetContentType(guid);
            var pageType  = modelType.BaseType;
            var model     = EditorReflectionService.GetDefault(pageType);

            ((Content)model).ContentTypeGuid = guid;
            content.ModelAsJson = JsonConvert.SerializeObject(model, Formatting.None, new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full
            });

            ParentId   = parentId;
            Properties = _editorReflectionService.GetModelProperties(content, out var _);
            //ContentModel = JsonConvert.DeserializeObject(content.ModelAsJson, content.ModelType) as IContent;
            ContentTypeGuid = guid;
        }
示例#2
0
        public async Task OnGetAsync(int id, int?version)
        {
            var content = await _contentRepository.GetContent(id);

            var contentVersion = await _contentVersionRepository.GetContent(version ?? content.SavedVersion);

            var contentVersions = await _contentVersionRepository.GetAll(content.Id);

            Id       = content.Id;
            ParentId = contentVersion?.ParentId ?? content.ParentId;
            Name     = contentVersion?.Name ?? content.Name;
            UrlSlug  = contentVersion?.UrlSlug ?? content.UrlSlug;

            Properties = _editorReflectionService.GetModelProperties((IContent)contentVersion ?? content, out var modelType);

            ContentTypeGuid  = modelType.GetPageDataValues().Guid;
            SavedVersion     = contentVersion?.Id ?? 0;
            PublishedVersion = content.PublishedVersion;
            Published        = content.Published;
            ContentVersions  = contentVersions.OrderByDescending(w => w.Id);
            AllowedGroups    = contentVersion != null ? contentVersion.AllowedGroups : content.AllowedGroups;

            //ContentModel = JsonConvert.DeserializeObject(content.ModelAsJson, content.ModelType) as IContent;
        }