public async Task Create(TesisDirigida TD) { try { _ctx.TesisDirigida.Add(TD); await _ctx.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task <int> CreateByBecarioDirigido(TesisDirigida TD) { try { TesisDirigida obj = _ctx.TesisDirigida.Add(TD); await _ctx.SaveChangesAsync(); return(obj.TesisDirigidaId); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task <IHttpActionResult> Update(TesisDirigida Obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.Update(Obj); return(Ok(Obj)); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> Create(TesisDirigida TD) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.Create(TD); return(Ok("Registro creado correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> ValidarDuplicados(TesisDirigida Obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); var exis = await _repository.ValidarDuplicados(Obj); return(Ok(exis)); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task <IHttpActionResult> UpdateEstado(TesisDirigida 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)); } }
/// <summary> /// Valida que no existan registros de tesis dirigidas /// </summary> /// <param name="model"><TesisDirigida>model</param> /// <returns>Boolean</returns> public async Task <Boolean> ValidarDuplicados(TesisDirigida model) { try { var registros = await _ctx.TesisDirigida.Where(e => e.ClavePersona == model.ClavePersona && e.GradoAcademicoId == model.GradoAcademicoId && DbFunctions.TruncateTime(e.FechaInicio) == DbFunctions.TruncateTime(model.FechaInicio) && DbFunctions.TruncateTime(e.FechaTermino) == DbFunctions.TruncateTime(model.FechaTermino) && e.TesisDirigidaId != model.TesisDirigidaId).AsNoTracking().CountAsync(); if (registros > 0) { return(true); } return(false); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task UpdateEstado(TesisDirigida TD) { try { var result = await _ctx.TesisDirigida.FirstOrDefaultAsync(e => e.TesisDirigidaId == TD.TesisDirigidaId); if (result != null) { result.EstadoFlujoId = TD.EstadoFlujoId; await _ctx.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(TesisDirigida TD)// UpdateSolicitud { try { if (TD.EstadoFlujoId == 1 && TD.BecarioDirigidoId != null) { var becario = await _ctx.BecarioDirigido.FirstOrDefaultAsync(e => e.BecarioDirigidoId == TD.BecarioDirigidoId); if (becario != null) { becario.EstadoFlujoId = 2; await _ctx.SaveChangesAsync(); } } if (TD.EstadoFlujoId == 3 && TD.BecarioDirigidoId != null) { var becario = await _ctx.BecarioDirigido.FirstOrDefaultAsync(e => e.BecarioDirigidoId == TD.BecarioDirigidoId); if (becario != null) { becario.EstadoFlujoId = 3; becario.AdjuntoId = TD.AdjuntoId; becario.NombreBecario = TD.Autor; becario.TesisDirigidaId = TD.TesisDirigidaId; becario.ClavePersona = TD.ClavePersona; becario.FechaInicio = TD.FechaInicio; becario.FechaTermino = TD.FechaTermino; //becario.FechaTermino = TD.FechaTermino; becario.TipoBecaId = TD.GradoAcademicoId; becario.NombreEstancia = TD.Titulo; becario.FechaValidacion = TD.FechaValidacion; await _ctx.SaveChangesAsync(); } } ////Agregar a OC if (TD.EstadoFlujoId == 3) { await new NuevoOCRepository().Create( new NuevoOC("CH", "TesisDirigida", TD.Titulo, "IndexCH.html#/detallestesisdirigida/" + TD.TesisDirigidaId + "/", TD.TesisDirigidaId + "" )); } ///////////////// var result = await _ctx.TesisDirigida.FirstOrDefaultAsync(e => e.TesisDirigidaId == TD.TesisDirigidaId); if (TD.EstadoFlujoId == 1 && result.EstadoFlujoId == 3) { await new NuevoOCRepository().DeleteId("TesisDirigida", TD.TesisDirigidaId + ""); } if (result != null) { if (TD.Adjunto != null) { //Eliminar archivo AdjuntoRepository adjuntoRepo = new AdjuntoRepository(); if (TD.Adjunto.nombre == "eliminar") { int id = Convert.ToInt32(TD.Adjunto.AdjuntoId); result.AdjuntoId = null; await _ctx.SaveChangesAsync(); await adjuntoRepo.Delete(id); } ///Agregar archivo al editar if (TD.Adjunto.AdjuntoId == 0) { if (result.AdjuntoId != null) { var id = result.AdjuntoId; result.AdjuntoId = null; await _ctx.SaveChangesAsync(); await adjuntoRepo.Delete(id); } Adjunto key = await adjuntoRepo.CreateAd(TD.Adjunto); TD.AdjuntoId = key.AdjuntoId; TD.Adjunto.AdjuntoId = key.AdjuntoId; } } _ctx.Entry(result).CurrentValues.SetValues(TD); await _ctx.SaveChangesAsync(); } PersonasRepository prep = new PersonasRepository(); Personas p = await prep.GetByClave(TD.ClavePersona); p.ultimaActualizacion = DateTime.Now; await prep.Update(p); } catch (Exception e) { throw new Exception(e.Message, e); } }