Beispiel #1
0
        public async Task Update(FactorInnovacion model)
        {
            try
            {
                var _model = await dbGI.DbSetFactorInnovacion.FirstOrDefaultAsync(e => e.Id == model.Id);

                if (_model != null)
                {
                    if (!model.ExisteEn(dbGI.DbSetFactorInnovacion.Where(e => e.Id != model.Id).Select(e => e.Descripcion).ToList()))
                    {
                        dbGI.Entry(_model).CurrentValues.SetValues(model);
                        await dbGI.SaveChangesAsync();
                    }
                    else
                    {
                        throw new ApplicationException("Ya existe un registro con ese nombre.");
                    }
                }
            }
            catch (ApplicationException e)
            {
                throw new ApplicationException(e.Message, e);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(ComiteGI model)
        {
            try
            {
                var _model = await dbGI.DbSetComiteGI.FirstOrDefaultAsync(e => e.comiteId == model.comiteId);

                if (_model != null)
                {
                    if (!model.ExisteEn(dbGI.DbSetComiteGI.Where(e => e.comiteId != model.comiteId).Select(e => e.Nombre).ToList(), "Nombre"))
                    {
                        dbGI.Entry(_model).CurrentValues.SetValues(model);
                        await dbGI.SaveChangesAsync();
                    }
                    else
                    {
                        throw new ApplicationException("Ya existe un registro con ese nombre.");
                    }
                }
            }
            catch (ApplicationException e)
            {
                throw new ApplicationException(e.Message, e);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(PlanNegocioEvolutivo model, String clavePersona, String nombrePersona)
        {
            try
            {
                var _model = await dbGI.DbSetPlanNegocioEvolutivo.FirstOrDefaultAsync(e => e.PlanNegocioEvolutivoId == model.PlanNegocioEvolutivoId);

                if (_model != null)
                {
                    var fecha = DateTime.Now;
                    dbGI.Entry(_model).CurrentValues.SetValues(model);
                    await dbGI.SaveChangesAsync();

                    await this.UpdateArchivos(model);

                    await this.UpdateGerencias(model);

                    await this.UpdateAutores(model);

                    await this.AddBitacoraMovimiento(model, clavePersona, nombrePersona, "Actualización del registro");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(MiembrosGI model)
        {
            try
            {
                var _model = await _db.DbSetMiembrosGI.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(ProductoHistorialFI model)
        {
            try
            {
                var _model = await context.DbSetProductoHistorialFI.FirstOrDefaultAsync(e => e.Id == model.Id);

                if (_model != null)
                {
                    context.Entry(_model).CurrentValues.SetValues(model);
                    await context.SaveChangesAsync();
                }
            }catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Beispiel #6
0
        public async Task Update(TecnologiaLicenciada model, String clavePersona, String nombrePersona)
        {
            try
            {
                var _model = await dbGI.DbSetTecnologiaLicenciada.FirstOrDefaultAsync(e => e.TecnologiaLicenciadaId == model.TecnologiaLicenciadaId);

                if (_model != null)
                {
                    if (model.Gerencias.Count > 0)
                    { //Se remueven las viejas gerencias
                        var oldGerencias = await dbGI.DbSetTecnologiaLicenciadaGerencia.Where(e => e.TecnologiaLicenciadaId == model.TecnologiaLicenciadaId).ToListAsync();

                        if (oldGerencias.Count > 0)
                        {
                            dbGI.DbSetTecnologiaLicenciadaGerencia.RemoveRange(oldGerencias);
                        }
                        dbGI.DbSetTecnologiaLicenciadaGerencia.AddRange(model.Gerencias);
                    }

                    //Verificamos la existencia de una notificacion como nuevo OC
                    var infoAgregada = await dbGEN.dbSetNuevoOC.Where(e => e.descripcion.Equals(_model.NombreTecnologiaLic)).FirstOrDefaultAsync();

                    if (infoAgregada != null && model.EstadoLicenciamientoId != 1)
                    {
                        NuevoOCRepository repo = new NuevoOCRepository();
                        await repo.Delete(infoAgregada.NuevoOCId);
                    }
                    if (infoAgregada == null && model.EstadoLicenciamientoId == 1)  //En caso de estar vigente la tecnologia se crea una notificacion de nuevo OC
                    {
                        NuevoOCRepository nuevo = new NuevoOCRepository();
                        await nuevo.Create(new NuevoOC("GI", "STL", model.NombreTecnologiaLic,
                                                       "indexGI.html#/detallestecnologiaLicenciada/" + model.TecnologiaLicenciadaId,
                                                       model.TecnologiaLicenciadaId.ToString()
                                                       ));
                    }

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

                    await this.AddBitacoraMovimiento(model, clavePersona, nombrePersona, "Actualización de STL");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Beispiel #7
0
        public async Task Update(ContribucionAutor model)
        {
            try
            {
                var _model = await dbGI.DbSetContribucionAutor.FirstOrDefaultAsync(e => e.Id == model.Id);

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

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

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

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

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

                if (_model.AdjuntoId != null)
                {
                    var id = _model.AdjuntoId;
                    _model.AdjuntoId = null;
                    await dbGI.SaveChangesAsync();

                    await new AdjuntoRepository().Delete(id);
                }

                if (model.Adjunto != null)
                {
                    Adjunto key = await _adjuntoRepo.CreateAd(model.Adjunto);

                    model.AdjuntoId         = key.AdjuntoId;
                    model.Adjunto.AdjuntoId = key.AdjuntoId;
                }
                else
                {
                    model.AdjuntoId = null;
                }


                if (_model != null)
                {
                    if (model.EstadoFlujoId == 14)
                    {
                        model.FechaRegistro = DateTime.Now;
                    }
                    ;
                    dbGI.Entry(_model).CurrentValues.SetValues(model);
                    await dbGI.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task Update(IdeaInnovadora model, List <AutoresIdea> listaAutores)
        {
            //throw new Exception("foo");
            try
            {
                var _model = await dbGI.DbSetIdeaInnovadora.FirstOrDefaultAsync(e => e.IdeaInnovadoraId == model.IdeaInnovadoraId);

                if (_model.AdjuntoId != null)
                {
                    var id = _model.AdjuntoId;
                    _model.AdjuntoId = null;
                    await dbGI.SaveChangesAsync();

                    await new AdjuntoRepository().Delete(id);
                }
                if (model.Adjunto != null)
                {
                    Adjunto key = await _adjuntoRepo.CreateAd(model.Adjunto);

                    model.AdjuntoId         = key.AdjuntoId;
                    model.Adjunto.AdjuntoId = key.AdjuntoId;
                }
                else
                {
                    model.AdjuntoId = null;
                }

                if (model.EstadoFlujoId == 14)
                {
                    model.FechaRegistro = DateTime.Now;
                }
                ;


                if (_model != null)
                {
                    dbGI.Entry(_model).CurrentValues.SetValues(model);
                    await dbGI.SaveChangesAsync();
                }
                try
                {
                    if (listaAutores.Count > 0)
                    {
                        foreach (var autor in listaAutores)
                        {
                            if (autor.Persona.Equals("eliminar"))
                            {
                                var _proponenteExist = await dbGI.DbSetAutoresIdea.FirstOrDefaultAsync(e => e.Id == autor.Id);

                                if (_proponenteExist != null)
                                {
                                    dbGI.DbSetAutoresIdea.Remove(_proponenteExist); await dbGI.SaveChangesAsync();
                                }
                            }
                            if (autor.IdeaInnovadoraId == 0)
                            {
                                autor.ContribucionProponente = null;
                                autor.IdeaInnovadoraId       = model.IdeaInnovadoraId;
                                var result = dbGI.DbSetAutoresIdea.Add(autor);
                                await dbGI.SaveChangesAsync();
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message, e);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }