private async Task DeleteCustomer(int customerID, CancellationToken cancellationToken) { var customer = await _dbContext.Customers.FindAsync(customerID, cancellationToken); _dbContext.Customers.Remove(customer); await _dbContext.SaveChangesAsync(cancellationToken); }
public async Task Handle(OrderCreatedV1Notification notification, CancellationToken cancellationToken) { var customer = await _dbContext.Customers.SingleOrDefaultAsync(i => i.ID == notification.CustomerID && i.HasOrders == false, cancellationToken); if (customer == null) { return; } customer.HasOrders = true; await _dbContext.SaveChangesAsync(cancellationToken); }
public Task SaveChanges(CancellationToken cancellationToken) => _dbContext.SaveChangesAsync(cancellationToken);
private async Task UpdateCustomer(Customer customer, CancellationToken cancellationToken) { _dbContext.Update(customer); await _dbContext.SaveChangesAsync(cancellationToken); }