using FluentValidation; using Raven.Client; using Raven.Client.Documents; using Raven.Client.Documents.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using zero.Core.Entities; using zero.Core.Extensions; namespace zero.Core.Collections { public abstract class TreeCollectionBase : CollectionBase, ITreeCollectionBase, IDisposable where T : IZeroEntity, ITreeEntity { public TreeCollectionBase(IZeroContext context, ICollectionInterceptorHandler interceptorHandler, IValidator validator = null) : base(context, interceptorHandler, validator) { } ///// //public async Task> GetHierarchy(string id) //{ // Categories_ByHierarchy.Result result = await Session.Query() // .ProjectInto() // .Include(x => x.Path.Select(p => p.Id)) // .FirstOrDefaultAsync(x => x.Id == id); // if (result == null) // { // return new(); // } // return (await Session.LoadAsync(result.Path.Select(x => x.Id))).Select(x => x.Value).ToList(); //} } public interface ITreeCollectionBase : ICollectionBase where T : IZeroEntity, ITreeEntity { ///// ///// Get the tree hierarchy path for this entity ///// //Task> GetHierarchy(string id); ///// ///// Update sorting of entities on a specific level ///// //Task>> SaveSorting(string[] sortedIds); ///// ///// Move an entity to a new parent ///// //Task> Move(string id, string parentId); ///// ///// Copies an entity to a new location ///// //Task> Copy(string id, string destinationId, bool includeDescendants = false); } }