Ejemplo n.º 1
0
        public async Task <IActionResult> Put([FromBody] Customer customer)
        {
            try
            {
                var dbCustomer = await customers.GetCustomerNoTracking(customer.Id);

                if (dbCustomer == null)
                {
                    return(NotFound(new { Id = customer.Id, error = "No customer with an id of " + customer.Id + " to update." }));
                }

                await customers.UpdateCustomer(customer);

                return(Ok(customer));
            }
            catch (DbUpdateException)
            {
                return(BadRequest());
            }
        }