示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageProfile" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="folders">The folders.</param>
 /// <exception cref="System.ArgumentNullException">name</exception>
 public PackageProfile(string name, params AssetFolder[] folders)
     : this()
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     Name = name;
     AssetFolders.AddRange(folders);
 }
        public async Task CreateAsync(AssetFolder folder)
        {
            folder.CreatedAt  = DateTimeService.Current();
            folder.ModifiedAt = folder.CreatedAt;

            var mongo = folder.ToMongo();

            await AssetFolders.InsertOneAsync(mongo);

            folder.Id = mongo.Id;
        }
        public async Task <AssetFolder> GetAssetFolderAsync(Guid id)
        {
            var entity = AssetFolders.AsQueryable().FirstOrDefault(x => x.Id == id);

            if (entity == null)
            {
                throw new Exception();
            }

            return(entity.ToModel());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PackageProfile" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="folders">The folders.</param>
 /// <exception cref="System.ArgumentNullException">name</exception>
 public PackageProfile(string name, params AssetFolder[] folders)
     : this()
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     Name = name;
     foreach (var folder in folders)
     {
         AssetFolders.Add(folder);
     }
 }
        public async Task <IEnumerable <AssetFolder> > GetAssetFoldersAsync(AssetFolderQuery queryData)
        {
            var query = AssetFolders.AsQueryable();

            if (queryData.RootOnly == true)
            {
                query = query.Where(x => x.Parent == null);
            }

            if (queryData.Parent != null)
            {
                query = query.Where(x => x.Parent == queryData.Parent.Value);
            }

            return(query.OrderBy(x => x.Name).ToList().Select(x => x.ToModel()));
        }
 public async Task UpdateAsync(AssetFolder folder)
 {
     await AssetFolders.ReplaceOneAsync(Builders <MongoAssetFolder> .Filter.Where(x => x.Id == folder.Id), folder.ToMongo());
 }