public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.Id) { return(BadRequest()); } _context.Update(customer); _context.Entry(customer).State = EntityState.Modified; //_context.Entry(customer.Address).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(Ok(customer)); }
public async Task <IActionResult> PutBroker([FromRoute] int id, [FromBody] Broker broker) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != broker.Id) { return(BadRequest()); } _context.Entry(broker).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BrokerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutShipment([FromRoute] int id, [FromBody] Shipment shipment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shipment.Id) { return(BadRequest()); } _context.Entry(shipment).State = EntityState.Modified; try { _context.Update(shipment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShipmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }