protected async Task UserUpdateKeys(User user) { using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); var entity = await dbContext.Users.FindAsync(user.Id); if (entity == null) { return; } entity.SecurityStamp = user.SecurityStamp; entity.Key = user.Key; entity.PrivateKey = user.PrivateKey; entity.RevisionDate = DateTime.UtcNow; await dbContext.SaveChangesAsync(); } }
public async Task UpdateUserKeysAndCiphersAsync(User user, IEnumerable <Core.Entities.Cipher> ciphers, IEnumerable <Core.Entities.Folder> folders, IEnumerable <Core.Entities.Send> sends) { using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); await UserUpdateKeys(user); var cipherEntities = Mapper.Map <List <Cipher> >(ciphers); await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, cipherEntities); var folderEntities = Mapper.Map <List <Folder> >(folders); await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, folderEntities); var sendEntities = Mapper.Map <List <Send> >(sends); await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, sendEntities); await dbContext.SaveChangesAsync(); } }