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; }
public override async Task <IContent> GetContent(int id, int?version = null) { return(await EZmsInMemoryCache.GetOrCreateAsync($"DefaultContentLoader:GetContent({id}, {version})", async entry => { entry.SetSlidingExpiration(TimeSpan.FromSeconds(10)); if (version.HasValue) { var cv = await _contentVersionRepository.GetContent(version.Value); if (cv != null) { return (IContent)cv; } } var content = await _repository.GetContent(id); if (content == null || !content.Published) { return null; } return (IContent)content; })); }