public async Task <ActionResult> Put(int productId, Product product) { this._logger.LogInformation($"Products/{productId} /PUT"); product.UpdatedAt = DateTimeOffset.UtcNow; using var db = new EvtContext(); var exists = await db.Set <Product>().AnyAsync(p => p.ProductId == productId); if (!exists) { return(NotFound()); } product.ProductId = productId; db.Update(product); await db.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Put(int customerId, Customer customer) { _logger.LogInformation($"Customers/{customerId} /PUT"); customer.UpdatedAt = DateTimeOffset.UtcNow; using var db = new EvtContext(); var exists = await db.Set <Customer>().AnyAsync(c => c.CustomerId == customerId); if (!exists) { return(NotFound()); } customer.CustomerId = customerId; db.Update(customer); await db.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Put(int orderId, Order order) { _logger.LogInformation($"Orders/{orderId} /PUT"); order.UpdatedAt = DateTimeOffset.UtcNow; using var db = new EvtContext(); var exists = await db.Set <Order>().AnyAsync(c => c.OrderId == orderId); if (!exists) { return(NotFound()); } order.OrderId = orderId; db.Update(order); await db.SaveChangesAsync(); return(NoContent()); }