public async Task <IActionResult> PutCandidatoEntity([FromRoute] int id, [FromBody] CandidatoEntity candidatoEntity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != candidatoEntity.id) { return(BadRequest()); } _context.Entry(candidatoEntity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CandidatoEntityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("id,name,username,email,phone,website")] CandidatoEntity candidatoEntity) { if (id != candidatoEntity.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(candidatoEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CandidatoEntityExists(candidatoEntity.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(candidatoEntity)); }
public async Task <IActionResult> Create([Bind("id,name,username,email,phone,website")] CandidatoEntity candidatoEntity) { if (ModelState.IsValid) { _context.Add(candidatoEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(candidatoEntity)); }
public async Task <IActionResult> PostCandidatoEntity([FromBody] CandidatoEntity candidatoEntity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Candidato.Add(candidatoEntity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCandidatoEntity", new { id = candidatoEntity.id }, candidatoEntity)); }
public ActionResult Put(CandidatoEntity entity) { try { var response = this._entityRepository.Update(entity); if (response) { return(Ok(new { status = true, message = entity })); } else { return(BadRequest(new { status = false, message = "Error actualizando el objeto" })); } } catch (Exception ex) { return(BadRequest(new { status = true, message = ex.Message })); } }
public ActionResult Post(CandidatoEntity entity) { try { entity.Id = Guid.NewGuid(); var response = this._entityRepository.Insert(entity); if (response) { return(Ok(new { status = true, message = entity })); } else { return(BadRequest(new { status = false, message = "Error creando el objeto" })); } } catch (Exception ex) { return(BadRequest(new { status = true, message = ex.Message })); } }