示例#1
0
                                                                   [HttpPost][Authorize] public async Task <IHttpActionResult> Create(LogrosReconocimientos 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)); }
                                                                   }
示例#2
0
                                                                   public async Task <IHttpActionResult> UpdateEstado(LogrosReconocimientos 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)); }
                                                                   }
示例#3
0
                                                                   public async Task <IHttpActionResult> Update(LogrosReconocimientos Obj)
                                                                   {
                                                                       try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                             if (Obj.Adjunto != null)
                                                                             {
                                                                                 //Elimar archivo
                                                                                 if (Obj.Adjunto.nombre == "eliminar")
                                                                                 {
                                                                                     int id = Convert.ToInt32(Obj.AdjuntoId);
                                                                                     Obj.AdjuntoId = null;
                                                                                     await _repository.Update(Obj);

                                                                                     await _adjuntoRepo.Delete(id);

                                                                                     return(Ok());
                                                                                 }
                                                                                 ///Agregar archivo al editar
                                                                                 if (Obj.Adjunto.AdjuntoId == 0)
                                                                                 {
                                                                                     Adjunto key = await _adjuntoRepo.CreateAd(Obj.Adjunto);

                                                                                     Obj.AdjuntoId         = key.AdjuntoId;
                                                                                     Obj.Adjunto.AdjuntoId = key.AdjuntoId;
                                                                                     await _repository.Update(Obj);

                                                                                     return(Ok(key));
                                                                                 }
                                                                             }
                                                                             //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)); }
                                                                   }
                                                                 public async Task UpdateEstado(LogrosReconocimientos Obj)
                                                                 {
                                                                     try
                                                                     {
                                                                         var result = await _ctx.dbSetLogrosReconocimientos.FirstOrDefaultAsync(e => e.LogrosReconocimientosId == Obj.LogrosReconocimientosId);

                                                                         if (result != null)
                                                                         {
                                                                             result.EstadoFlujoId = Obj.EstadoFlujoId;

                                                                             await _ctx.SaveChangesAsync();
                                                                         }
                                                                     }
                                                                     catch (Exception e)
                                                                     {
                                                                         throw new Exception(e.Message, e);
                                                                     }
                                                                 }
                                                                 public async Task Update(LogrosReconocimientos Obj)// UpdateSolicitud
                                                                 {
                                                                     try
                                                                     {
                                                                         var result = await _ctx.dbSetLogrosReconocimientos.FirstOrDefaultAsync(e => e.LogrosReconocimientosId == Obj.LogrosReconocimientosId);

                                                                         if (result != null)
                                                                         {
                                                                             _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(LogrosReconocimientos Obj)
 {
     try
     {
         _ctx.dbSetLogrosReconocimientos.Add(Obj);
         await _ctx.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }