public async Task <IActionResult> PutMayorDto([FromRoute] int id, [FromBody] MayorDto mayorDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mayorDto.Id) { return(BadRequest()); } _context.Entry(mayorDto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MayorDtoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostMayorDto([FromBody] MayorDto mayorDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MayorDto.Add(mayorDto); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMayorDto", new { id = mayorDto.Id }, mayorDto)); }