public async Task <IActionResult> PutProduct(int id, ProductDTO productDTO) { if (id != productDTO.Id) { return(BadRequest()); } var product = _mapper.Map <Product>(productDTO); _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomer(int id, CustomerDTO customerDTO) { if (id != customerDTO.Id) { return(BadRequest()); } var customer = _mapper.Map <Customer>(customerDTO); _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }