public async Task Update(ListadoEmpleadosSind model)
        {
            try
            {
                var _model = await _db.listadoEmpleadosSind.FirstOrDefaultAsync(e => e.Id == model.Id);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(EvaluacionEmpleadosCompetenciasConductuales model)
        {
            try
            {
                var _model = await _db.evaluacionesConductuales.FirstOrDefaultAsync(e => e.EvaluacionId == model.EvaluacionId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(RegistroEvaluacionesSind model)
        {
            try
            {
                var _model = await _db.registroEvaluacionSind.FirstOrDefaultAsync(e => e.id == model.id);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 4
0
        public async Task Update(MatrizCompetenciasSind model)
        {
            try
            {
                var _model = await _db.matrizCompetenciasSin.FirstOrDefaultAsync(e => e.id == model.id);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 5
0
        public async Task Update(FamiliasPuestos model)
        {
            try
            {
                var _model = await _db.familiaPuestos.FirstOrDefaultAsync(e => e.FamiliaId == model.FamiliaId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 6
0
                                               public async Task Update(SNI sni)
                                               {
                                                   try
                                                   {
                                                       var _sni = await _ctx.SNI.FirstOrDefaultAsync(e => e.SNIId == sni.SNIId);

                                                       if (_sni != null)
                                                       {
                                                           if (sni.Adjunto != null)
                                                           {
                                                               //Eliminar archivo
                                                               if (sni.Adjunto.nombre == "eliminar")
                                                               {
                                                                   int id = Convert.ToInt32(sni.Adjunto.AdjuntoId);
                                                                   _sni.AdjuntoId = null;
                                                                   await _ctx.SaveChangesAsync();

                                                                   await new  AdjuntoRepository().Delete(id);
                                                               }
                                                               ///Agregar archivo al editar
                                                               if (sni.Adjunto.AdjuntoId == 0)
                                                               {
                                                                   if (_sni.AdjuntoId != null)
                                                                   {
                                                                       var id = _sni.AdjuntoId;
                                                                       _sni.AdjuntoId = null;
                                                                       await _ctx.SaveChangesAsync();

                                                                       await new AdjuntoRepository().Delete(id);
                                                                   }
                                                                   Adjunto key = await new AdjuntoRepository().CreateAd(sni.Adjunto);
                                                                   sni.AdjuntoId         = key.AdjuntoId;
                                                                   sni.Adjunto.AdjuntoId = key.AdjuntoId;
                                                               }
                                                           }
                                                           _ctx.Entry(_sni).CurrentValues.SetValues(sni);

                                                           await _ctx.SaveChangesAsync();
                                                       }
                                                   }
                                                   catch (Exception e)
                                                   {
                                                       throw new Exception(e.Message, e);
                                                   }
                                               }
                                                             public async Task Update(EncargadoDespacho Obj)
                                                             {
                                                                 try
                                                                 {
                                                                     var result = await _ctx.EncargadoDespacho.FirstOrDefaultAsync(e => e.EncargadoDespachoId == Obj.EncargadoDespachoId);

                                                                     if (result != null)
                                                                     {
                                                                         _ctx.Entry(result).CurrentValues.SetValues(Obj);

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

                                                                            if (result != null)
                                                                            {
                                                                                _ctx.Entry(result).CurrentValues.SetValues(Obj);

                                                                                await _ctx.SaveChangesAsync();
                                                                            }
                                                                        }
                                                                        catch (Exception e)
                                                                        {
                                                                            throw new Exception(e.Message, e);
                                                                        }
                                                                    }
Ejemplo n.º 9
0
                                                         /// <summary>
                                                         /// Actualiza un registro de la tabla de Certificacion
                                                         /// </summary>
                                                         /// <param name="Certificacion">objeto de tipo Certificacion con los nuevos datos</param>
                                                         /// <returns></returns>
                                                         public async Task Update(Certificacion Certificacion)
                                                         {
                                                             try
                                                             {
                                                                 var _Certificacion = await _ctx.Certificacion
                                                                                      .FirstOrDefaultAsync(e => e.CertificacionId == Certificacion.CertificacionId);

                                                                 if (_Certificacion != null)
                                                                 {
                                                                     _ctx.Entry(_Certificacion).CurrentValues.SetValues(Certificacion);
                                                                     await _ctx.SaveChangesAsync();
                                                                 }
                                                             }
                                                             catch (Exception e)
                                                             {
                                                                 throw new Exception(e.Message, e);
                                                             }
                                                         }
        public async Task Update(CapacitacionYcertificacion obj)
        {
            try
            {
                var _obj = await _ctx.dbSetCapacitacionYcertificacion.FirstOrDefaultAsync(e => e.CapacitacionYcertificacionId == obj.CapacitacionYcertificacionId);

                if (_obj != null)
                {
                    _ctx.Entry(_obj).CurrentValues.SetValues(obj);

                    await _ctx.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 11
0
                                                      public async Task Update(Distincion dis)
                                                      {
                                                          try
                                                          {
                                                              var _dis = await _ctx.Distincion.FirstOrDefaultAsync(e => e.DistincionId == dis.DistincionId);

                                                              if (_dis != null)
                                                              {
                                                                  if (dis.Adjunto != null)
                                                                  {
                                                                      //Eliminar archivo
                                                                      if (dis.Adjunto.nombre == "eliminar")
                                                                      {
                                                                          int id = Convert.ToInt32(dis.Adjunto.AdjuntoId);
                                                                          _dis.AdjuntoId = null;
                                                                          await _ctx.SaveChangesAsync();

                                                                          await new AdjuntoRepository().Delete(id);
                                                                      }
                                                                      ///Agregar archivo al editar
                                                                      if (dis.Adjunto.AdjuntoId == 0)
                                                                      {
                                                                          if (_dis.AdjuntoId != null)
                                                                          {
                                                                              var id = _dis.AdjuntoId;
                                                                              _dis.AdjuntoId = null;
                                                                              await _ctx.SaveChangesAsync();

                                                                              await new AdjuntoRepository().Delete(id);
                                                                          }
                                                                          var key = await new AdjuntoRepository().CreateAd(dis.Adjunto);
                                                                          dis.AdjuntoId         = key.AdjuntoId;
                                                                          dis.Adjunto.AdjuntoId = key.AdjuntoId;
                                                                      }
                                                                  }
                                                                  _ctx.Entry(_dis).CurrentValues.SetValues(dis);
                                                                  await _ctx.SaveChangesAsync();
                                                              }
                                                          }
                                                          catch (Exception e)
                                                          {
                                                              throw new Exception(e.Message, e);
                                                          }
                                                      }
Ejemplo n.º 12
0
        /// <summary>
        /// Actualiza un becario
        /// </summary>
        /// <param name="model">becario con los nuevos valores</param>
        /// <returns></returns>
        public async Task Update(BecarioExternoINEEL model)
        {
            try
            {
                var _model = await _dbch.BecarioExternoINEEL
                             .FirstOrDefaultAsync(e => e.BecarioId == model.BecarioId);

                if (_model != null)
                {
                    if (model.Adjunto != null)
                    {
                        Adjunto key = await new AdjuntoRepository().CreateAd(model.Adjunto);
                        model.AdjuntoId = key.AdjuntoId;
                    }

                    if (model.EstadoFlujoId == 3)
                    {
                        NuevoOCRepository repo = new NuevoOCRepository();
                        await repo.Create("CH", "BecarioDirigido", _model.NombreBecario, "indexCH.html#/InformeBecarioDetails/" + _model.BecarioId, Convert.ToString(_model.BecarioId));
                    }
                    else
                    {
                        var notificacion = await _dbgen.dbSetNuevoOC.Where(e => e.OcsId.Equals("BecarioDirigido") && e.IdExterno == _model.BecarioId + "").AsNoTracking().FirstOrDefaultAsync();;
                        if (notificacion != null)
                        {
                            NuevoOCRepository repo = new NuevoOCRepository();
                            await repo.DeleteId("BecarioDirigido", _model.BecarioId + "");
                        }
                    }

                    _dbch.Entry(_model).CurrentValues.SetValues(model);
                    await _dbch.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 13
0
                                                         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);
                                                             }
                                                         }
Ejemplo n.º 14
0
        public async Task Update(Publicacion Obj)// UpdateSolicitud
        {
            try
            {
                var result = await _ctx.Publicacion.FirstOrDefaultAsync(e => e.PublicacionId == Obj.PublicacionId);

                // if(await ValidarDuplicados(Obj))
                // {
                //     throw new ApplicationException("Intente cambiar la revista asociada, la fecha de publicación o el número de páginas");
                // }
                if (Obj.EstadoFlujoId == 1 && result.EstadoFlujoId == 3)
                {
                    await new NuevoOCRepository().DeleteId("ArtículoCH", result.PublicacionId + "");
                }
                if (result != null)
                {
                    if (Obj.Adjunto != null)
                    {
                        AdjuntoRepository _adjuntoRepo = new AdjuntoRepository();
                        if (Obj.Adjunto.nombre == "eliminar")
                        {
                            int id = Convert.ToInt32(Obj.Adjunto.AdjuntoId);
                            Obj.AdjuntoId = null;
                            _ctx.Entry(result).CurrentValues.SetValues(Obj);
                            await _ctx.SaveChangesAsync();

                            await _adjuntoRepo.Delete(id);
                        }
                        ///Agregar archivo al editar
                        if (Obj.Adjunto.AdjuntoId == 0)
                        {
                            if (result.AdjuntoId != null)
                            {
                                var id = result.AdjuntoId;
                                Obj.AdjuntoId = null;
                                _ctx.Entry(result).CurrentValues.SetValues(Obj);
                                await _ctx.SaveChangesAsync();

                                await _adjuntoRepo.Delete(id);
                            }
                            Adjunto key = await _adjuntoRepo.CreateAd(Obj.Adjunto);

                            Obj.AdjuntoId = key.AdjuntoId;
                        }
                    }

                    _ctx.Entry(result).CurrentValues.SetValues(Obj);

                    await _ctx.SaveChangesAsync();
                }

                //if (Obj.EstadoFlujoId == 3)
                //{
                //    await new NuevoOCRepository().Create(
                //    new NuevoOC("MT",
                //               "ARTÍCULO",
                //    Obj.TituloPublicacion,
                //    "indexMT.html#/PublicacionDetails/" + Obj.PublicacionId
                //        ));
                //}


                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);
            }
        }
Ejemplo n.º 15
0
        public async Task Update(BecarioExterno model)
        {
            try
            {
                var _model = await _db.BecarioExterno
                             .FirstOrDefaultAsync(e => e.BecarioExternoId == model.BecarioExternoId);

                if (model.EstadoFlujoId == 1 && _model.EstadoFlujoId == 3)
                {
                    await new NuevoOCRepository().DeleteId("BecarioExterno", _model.BecarioExternoId + "");
                }
                if (_model != null)
                {
                    foreach (var adjuntoBecarioExterno in model.AdjuntoBecarioExterno)
                    {
                        if (adjuntoBecarioExterno.Adjunto != null)
                        {
                            try
                            {
                                if (adjuntoBecarioExterno.Adjunto.AdjuntoId < 1) //NUEVO ADJUNTO
                                {
                                    _dbGen.dbSetAdjuntos.Add(adjuntoBecarioExterno.Adjunto);
                                    await _dbGen.SaveChangesAsync(); //guardar el adjunto

                                    adjuntoBecarioExterno.AdjuntoId        = adjuntoBecarioExterno.Adjunto.AdjuntoId;
                                    adjuntoBecarioExterno.BecarioExternoId = model.BecarioExternoId;
                                    //guardar nuevo adjuntoBecarioExterno
                                    _db.AdjuntoBecarioExterno.Add(adjuntoBecarioExterno);
                                    await _db.SaveChangesAsync(); //guardar el adjunto

                                    _dbGen = new GEN_Context();
                                }
                                else //adjunto existente: actualizar el adjunto
                                {
                                    if (adjuntoBecarioExterno.Adjunto.nombre.Equals("eliminar"))
                                    {
                                        var _adjuntoBe = await _db.AdjuntoBecarioExterno.FirstOrDefaultAsync(e => e.AdjuntoId == adjuntoBecarioExterno.Adjunto.AdjuntoId);

                                        if (_adjuntoBe != null)
                                        {
                                            _db.AdjuntoBecarioExterno.Remove(_adjuntoBe);
                                            await _db.SaveChangesAsync();
                                        }
                                    }
                                    else
                                    {
                                        var _modelAdjunto = await _dbGen.dbSetAdjuntos.FirstOrDefaultAsync(e => e.AdjuntoId == adjuntoBecarioExterno.Adjunto.AdjuntoId);

                                        _dbGen.Entry(_modelAdjunto).CurrentValues.SetValues(adjuntoBecarioExterno.Adjunto);
                                        await _dbGen.SaveChangesAsync();
                                    }
                                    //if (model.EstadoFlujoId == 3)
                                    //{
                                    //    await new NuevoOCRepository().Create(
                                    //    new NuevoOC("CH",
                                    //               "IBE",
                                    //    model.Titulo,
                                    //    "indexMT.html#/InformeBecariooDetails/" + model.BecarioExternoId
                                    //        ));
                                    //}
                                }
                            }
                            catch (Exception e)
                            {
                                throw new Exception(e.Message, e);
                            }
                        }
                    }

                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();


                    PersonasRepository prep = new PersonasRepository();
                    Personas           p    = await prep.GetByClave(model.Asesor_ClavePersona);

                    p.ultimaActualizacion = DateTime.Now;
                    await prep.Update(p);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }