namespace zero.Pages; public class PagesStore : TreeEntityStore, IPagesStore { protected IPageTypeService PageTypes { get; private set; } public PagesStore(IStoreContext context, IPageTypeService pageTypes) : base(context) { PageTypes = pageTypes; } /// public override async Task IsAllowedAsChild(Page model, string parentId) { IList pageTypes = await PageTypes.GetAllowedPageTypes(parentId); return pageTypes.Any(x => x.Alias == model.PageTypeAlias); } /// public async Task Empty(string pageType, string parentId = null) { PageType type = PageTypes.GetPageType(pageType); if (type == null) { return null; } Page model = await Empty(); model.PageTypeAlias = type.Alias; model.ParentId = parentId; if (!await IsAllowedAsChild(model, parentId)) { return null; // TODO we have no way to return an error here :-/ } return model; } } public interface IPagesStore : ITreeEntityStore { /// /// Get new instance of an entity for a specific page type /// Task Empty(string pageType, string parentId = null); }