public async Task <IActionResult> PutPratos([FromRoute] int id, [FromBody] PratosDTO pratos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pratos.IdPratos) { return(BadRequest()); } _context.Entry(pratos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PratosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostPratos([FromBody] PratosDTO pratos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (pratos.IdPratos > 0) { await PutPratos(pratos.IdPratos, pratos); } else { _context.pratos.Add(pratos); await _context.SaveChangesAsync(); } return(CreatedAtAction("GetPratos", new { id = pratos.IdPratos }, pratos)); }