public async Task <IHttpActionResult> Update(ExperienciaDocente Obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); //solución de ALAN replicada //if (Obj.Adjunto != null) // Obj.AdjuntoId = Obj.Adjunto.AdjuntoId; await _repository.Update(Obj); return(Ok(Obj)); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
[HttpPost][Authorize] public async Task <IHttpActionResult> Create(ExperienciaDocente Obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.Create(Obj); return(Ok("Registro creado correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> UpdateEstado(ExperienciaDocente Obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.UpdateEstado(Obj); return(Ok("Registro actualizado correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task UpdateEstado(ExperienciaDocente Obj) { try { var result = await _ctx.ExperienciaDocente.FirstOrDefaultAsync(e => e.ExperienciaDocenteId == Obj.ExperienciaDocenteId); if (result != null) { result.EstadoFlujoId = Obj.EstadoFlujoId; await _ctx.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(ExperienciaDocente Obj)// UpdateSolicitud { try { var result = await _ctx.ExperienciaDocente.FirstOrDefaultAsync(e => e.ExperienciaDocenteId == Obj.ExperienciaDocenteId); if (result != null) { if (Obj.Adjunto != null) { //Elimar archivo if (Obj.Adjunto.nombre == "eliminar") { int id = Convert.ToInt32(Obj.Adjunto.AdjuntoId); Obj.AdjuntoId = null; result.AdjuntoId = null; await _ctx.SaveChangesAsync(); await new AdjuntoRepository().Delete(id); } ///Agregar archivo al editar if (Obj.Adjunto.AdjuntoId == 0) { if (result.AdjuntoId != null) { var id = result.AdjuntoId; result.AdjuntoId = null; await _ctx.SaveChangesAsync(); await new AdjuntoRepository().Delete(id); } Adjunto key = await new AdjuntoRepository().CreateAd(Obj.Adjunto); Obj.AdjuntoId = key.AdjuntoId; } } _ctx.Entry(result).CurrentValues.SetValues(Obj); await _ctx.SaveChangesAsync(); PersonasRepository prep = new PersonasRepository(); Personas p = await prep.GetByClave(Obj.ClavePersona); p.ultimaActualizacion = DateTime.Now; await prep.Update(p); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Create(ExperienciaDocente Obj) { try { _ctx.ExperienciaDocente.Add(Obj); await _ctx.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }