private async Task DeleteOrder(int orderID, CancellationToken cancellationToken) { var order = await _dbContext.Orders.FindAsync(orderID); _dbContext.Orders.Remove(order); await _dbContext.SaveChangesAsync(cancellationToken); }
public async Task Handle(ProductDeletedV1Notification notification, CancellationToken cancellationToken) { var product = await _dbContext.Products.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken); if (product == null) { return; } _dbContext.Products.Remove(product); await _dbContext.SaveChangesAsync(cancellationToken); }
public async Task Handle(CustomerDeletedV1Notification notification, CancellationToken cancellationToken) { var customer = await _dbContext.Customers.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken); if (customer == null) { return; } _dbContext.Customers.Remove(customer); await _dbContext.SaveChangesAsync(cancellationToken); }
public async Task Handle(ProductCreatedV1Notification notification, CancellationToken cancellationToken) { var product = await _dbContext.Products.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken); if (product != null) { return; } _dbContext.Products.Add(new Product { ID = notification.ID }); await _dbContext.SaveChangesAsync(cancellationToken); }
private async Task CreateOrder(Order order, CancellationToken cancellationToken) { _dbContext.Orders.Add(order); await _dbContext.SaveChangesAsync(cancellationToken); }
private async Task CreateOrderItem(OrderItem orderItem, CancellationToken cancellationToken) { _dbContext.OrderItems.Add(orderItem); await _dbContext.SaveChangesAsync(cancellationToken); }
private async Task UpdateOrder(Order order, CancellationToken cancellationToken) { _dbContext.Update(order); await _dbContext.SaveChangesAsync(cancellationToken); }
private async Task UpdateOrderItem(UpdateOrderItemV1Command request, CancellationToken cancellationToken) { _dbContext.Update(request.OrderItem); await _dbContext.SaveChangesAsync(cancellationToken); }