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()); }
public async Task <IActionResult> PostCustomer([FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Customer.Add(customer); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomer", new { id = customer.Id }, customer)); }