public async Task <IActionResult> PostCortePorBarbeiro([FromBody] CortePorBarbeiro cortePorBarbeiro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CortePorBarbeiro.Add(cortePorBarbeiro); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (CortePorBarbeiroExists(cortePorBarbeiro.CorteIdCorte)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetCortePorBarbeiro", new { id = cortePorBarbeiro.CorteIdCorte }, cortePorBarbeiro)); }
public async Task <IActionResult> PutCortePorBarbeiro([FromRoute] int id, [FromBody] CortePorBarbeiro cortePorBarbeiro) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cortePorBarbeiro.CorteIdCorte) { return(BadRequest()); } _context.Entry(cortePorBarbeiro).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CortePorBarbeiroExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }