public async Task <ActionResult <TipoIdentificacionDTO> > PutTipoIdentificacion( int id, TipoIdentificacionDTO tipoIdentificacionDTO) { if (id != tipoIdentificacionDTO.Id) { return(BadRequest()); } var TipoIdentificacionItem = await _context.TipoIdentificacions.FindAsync(id); if (TipoIdentificacionItem == null) { return(NotFound()); } TipoIdentificacionItem.Nombre = tipoIdentificacionDTO.Nombre; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) when(!TipoIdentificacionItemExiste(id)) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult <TipoIdentificacionDTO> > PostTipoIdentificacion( TipoIdentificacionDTO tipoIdentificacionDTO) { var tipoIdentificacion = new TipoIdentificacion { Nombre = tipoIdentificacionDTO.Nombre }; _context.TipoIdentificacions.Add(tipoIdentificacion); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetTiposIdentificacion), new { id = tipoIdentificacion.Id }, TipoIdentificacionToDTO(tipoIdentificacion))); }