コード例 #1
0
        public async Task UpdateFolder(FolderModel folder, CancellationToken cancellationToken)
        {
            await using var context = contextFactory.CreateDbContext();
            var folderEntity = await FindFolder(context, folder.Id, cancellationToken);

            var updatedEntity = folder.ToEntity();

            context.Entry(folderEntity).CurrentValues.SetValues(updatedEntity);
            await context.SaveChangesAsync(cancellationToken);
        }
コード例 #2
0
        public async Task CreateEmptyFolder(FolderModel folder, CancellationToken cancellationToken)
        {
            var folderEntity = folder.ToEntity();

            await using var context = contextFactory.CreateDbContext();
            await context.Folders.AddAsync(folderEntity, cancellationToken);

            await context.SaveChangesAsync(cancellationToken);

            folder.Id = folderEntity.Id.ToItemId();
        }