public async Task <ActionResult <NestingBox> > CreateNestingBoxAsync([FromBody] NestingBox nestingBox) { // Create nesting box nestingBox = await _nestingBoxService.AddAsync(nestingBox, HttpContext.RequestAborted).ConfigureAwait(false); if (nestingBox == null) { return(Conflict()); } return(CreatedAtAction(nameof(GetNestingBoxByIdAsync), new { id = nestingBox.Id }, nestingBox)); }
public async Task <ActionResult <NestingBox> > GetNestingBoxByIdAsync(string id) { if (id == null) { throw new ArgumentNullException(nameof(id)); } // Retrieve nesting box NestingBox nestingBox = await _nestingBoxService.FindByIdAsync(id, HttpContext.RequestAborted).ConfigureAwait(false); if (nestingBox == null) { return(NotFound()); } return(nestingBox); }
public async Task <IActionResult> EditNestingBoxAsync(string id, [FromBody] NestingBox nestingBox) { if (nestingBox.Id == null) { nestingBox.Id = id; } else if (nestingBox.Id != id) { ModelState.AddModelError("NestingBox.Id", "Nesting box ID is set but different from the resource URL."); return(BadRequest(ModelState)); } // Edit nesting box nestingBox = await _nestingBoxService.UpdateAsync(nestingBox, HttpContext.RequestAborted).ConfigureAwait(false); if (nestingBox == null) { return(Conflict()); } return(NoContent()); }