public async Task RemoveGroup(string id) { var memberships = _db.GroupMemberships.Where(x => x.GroupId == id).ToList(); var group = await _db.Groups.FirstOrDefaultAsync(x => x.Id == id); _db.RemoveRange(memberships); _db.Remove(group); await _db.SaveChangesAsync(); }
public async Task <IdentityResult> DeleteExpiredAsync(CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); IEnumerable <RefreshToken> expiredRefreshTokens = await _context.RefreshTokens.Where(rt => rt.ExpirationDate <= DateTime.Now).ToListAsync(); _context.RemoveRange(expiredRefreshTokens); try { await _context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { return(IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure())); } return(IdentityResult.Success); }