public async Task <ActionResult <AreaInvestigacion> > PostAreaInvestigacion(AreaInvestigacion areaInvestigacion) { _context.AreaInvestigacion.Add(areaInvestigacion); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAreaInvestigacion", new { id = areaInvestigacion.AreaInvestigacionId }, areaInvestigacion)); }
public async Task <IActionResult> PutAreaInvestigacion(int id, AreaInvestigacion areaInvestigacion) { if (id != areaInvestigacion.AreaInvestigacionId) { return(BadRequest()); } _context.Entry(areaInvestigacion).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AreaInvestigacionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Create(AreaInvestigacion model) { try { _db.AreaInvestigacion.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(AreaInvestigacion model) { try { var _model = await _db.AreaInvestigacion.FirstOrDefaultAsync(e => e.AreaInvestigacionId == model.AreaInvestigacionId); if (_model != null) { _db.Entry(_model).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task UpdateEstado(AreaInvestigacion model) { try { var _model = await _db.AreaInvestigacion.FirstOrDefaultAsync(e => e.AreaInvestigacionId == model.AreaInvestigacionId); if (_model != null) { _model.Estado = model.Estado; await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task <IHttpActionResult> UpdateEstado([FromBody] AreaInvestigacion model) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _entityRepo.UpdateEstado(model); return(Ok()); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> Update([FromBody] AreaInvestigacion model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _entityRepo.Update(model); return(Ok("Registro actualizado exitosamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); //if (e.Message.Substring(0, 44) == "An error occurred while updating the entries") //{ // return BadRequest("El registro ya existe!"); //} return(InternalServerError(e)); } }