예제 #1
0
        public async Task SaveAsync(IEnumerable <FileInfoDto> newDtoFiles)
        {
            var categories = await GetOrCreateCategoriesFor(newDtoFiles);

            var newFiles = newDtoFiles.Select(dto =>
            {
                var withCategory = categories.Single(c => c.Name == dto.Category);
                return(FileInfo.From(dto, withCategory));
            }).ToList();

            await MakeIndexesUniqueFor(newFiles);

            await db.Files.SaveAsync(newFiles);

            await db.CommitChangesAsync();
        }