public async Task <IActionResult> PutCustomer(int id, CustomerDto customer) { Customer c = CustomerDto.FromCustomerDto(customer); if (id != c.Id) { return(BadRequest()); } _context.Entry(c).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <CustomerDto> > PostCustomer(CustomerDto customer) { Customer c = CustomerDto.FromCustomerDto(customer); _context.Customers.Add(c); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomer", new { id = customer.Id }, CustomerDto.ToCustomerDto(c))); }