public async Task <IActionResult> PostContainerYardLocation([FromBody] ContainerYardLocation containerYardLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ContainerYardLocation.Add(containerYardLocation); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ContainerYardLocationExists(containerYardLocation.ContainerYardLocationId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetContainerYardLocation", new { id = containerYardLocation.ContainerYardLocationId }, containerYardLocation)); }
public async Task <IActionResult> PutContainerYardLocation([FromRoute] long id, [FromBody] ContainerYardLocation containerYardLocation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != containerYardLocation.ContainerYardLocationId) { return(BadRequest()); } _context.Entry(containerYardLocation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContainerYardLocationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }