Ejemplo n.º 1
0
        public List <OrganismoSP> createOrganismo(string Nombre, int provinciaId, int localidadId, int regionId)
        {
            var organismo = new OrganismoDto();

            organismo.Nombre       = Nombre.Trim().ToUpper();
            organismo.Provincia_Id = provinciaId;
            organismo.Localidad_Id = localidadId;
            organismo.Region_Id    = regionId;
            organismo.Activo       = false;
            List <OrganismoSP> lista = new List <OrganismoSP>();
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(organismo);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "ORGANISMO", "Se ha creado el Organismo", null, organismo.Nombre, usuario, organismo.Id);
                context.Add(accion);
                context.SaveChanges();
                lista = context.Database
                        .SqlQuery <OrganismoSP>("GetOrganismosPorId @id", new SqlParameter("@id", organismo.Id))
                        .ToList();
            }
            return(lista);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> validarListaDniAgregarAlGrupo(List <List <string> > documentosAValidar)
        {
            //int? dni = null;
            string dni           = "";
            var    dniExistentes = new List <List <string> >();

            List <DenuncianteDto> denunciantes = new List <DenuncianteDto>();
            var grupo = new GrupoDto();

            using (NuevoDbContext context = new NuevoDbContext())
            {
                foreach (var item in documentosAValidar)
                {
                    DenuncianteDto nuevoDenunciante = new DenuncianteDto();

                    if (String.IsNullOrEmpty(item[4]))
                    {
                        if (!String.IsNullOrEmpty(item[3]))
                        {
                            dni = Convert.ToString(item[3]);
                            var nombre   = item[1];
                            var apellido = item[2];
                            if (context.Denunciantes.Where(d => String.Equals(d.NroDocumento.Trim(), dni.Trim()) &&
                                                           (!d.nombre.Contains(nombre) ||
                                                            !d.apellido.Contains(apellido))).Any())
                            {
                                dniExistentes.Add(item);
                            }
                        }
                        nuevoDenunciante.nombre   = item[1].ToUpper();
                        nuevoDenunciante.apellido = item[2].ToUpper();


                        context.Add(nuevoDenunciante);
                        await context.SaveChangesAsync();
                    }
                    else
                    {
                        var idExistente = Convert.ToInt32(item[4]);
                        nuevoDenunciante = await context.Denunciantes.Where(d => d.DenuncianteId == idExistente).FirstOrDefaultAsync();
                    }
                    denunciantes.Add(nuevoDenunciante);
                }
                if (dniExistentes.Count > 0)
                {
                    return(Json("Verifique los Nros de Documentos : " + dniExistentes));
                }

                grupo.grupoDenunciantes      = denunciantes;
                grupo.IdDenunciantePrincipal = denunciantes[0].DenuncianteId;
                context.Add(grupo);
                await context.SaveChangesAsync();
            }

            return(PartialView("ListGrupoDenunciantes", grupo));
        }
Ejemplo n.º 3
0
 public void createEvento(EventoDto evento, string usuario)
 {
     using (NuevoDbContext context = new NuevoDbContext())
     {
         context.Add(evento);
         context.SaveChanges();
         var logger = new CommonChangeLoggerDto(DateTime.Now, "EVENTO", "Se ha creado el Evento id : " + evento.EventoId + " relacionado a la Denuncia id : " + evento.DenunciaId, null, "Datos iniciales: " + "-Fecha Vencimiento : " + evento.Fecha + "Tipo de Evento: " + evento.TipoEventoId + "-Contestado " + ((evento.CONTESTADO == 1)?"SI":"NO"), usuario, evento.EventoId);
         context.Add(logger);
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        public DenunciaDto CreateDenuncia(DenunciaDto denuncia)
        {
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(denuncia);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIA", "Se ha creado La Denuncia con id:  " + denuncia.DenunciaId.ToString(), null, "ACTIVA", usuario, denuncia.DenunciaId);
                context.Add(accion);
                context.SaveChanges();
                return(denuncia);
            }
        }
Ejemplo n.º 5
0
        public DenuncianteDto crearDenunciante(DenuncianteDto test)
        {
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(test);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIANTE", "Se ha creado al Denunciante", null, "Denunciante " + test.apellido + "," + test.nombre + "," + " dni: " + test.NroDocumento, usuario, test.DenuncianteId);
                context.Add(accion);
                context.SaveChanges();
                return(test);
            }
        }
Ejemplo n.º 6
0
        private void loguearModificaciones(NuevoDbContext context, DateTime fechaCambio,
                                           string objetoModificado, string valorAnterior, string valorActual,
                                           string descripcion, string usuario, int objetoId)
        {
            var logger = new DenChLoggerDto();

            logger.FechaCambio      = fechaCambio;
            logger.ObjetoModificado = objetoModificado;
            logger.Descripcion      = descripcion;
            logger.ValorAnterior    = valorAnterior;
            logger.ValorActual      = valorActual;
            logger.Usuario          = usuario;
            logger.ObjetoId         = objetoId;
            context.Add(logger);
            context.SaveChanges();
            //context.Database
            //.ExecuteSqlCommand("Insert into tDenChLogger values(@fechaCambio,@objetoModificado,@descripcion,@valorAnterior,@valorActual,@usuario,@objetoId)"
            //, new SqlParameter("@fechaCambio", fechaCambio)
            //, new SqlParameter("@objetoModificado", objetoModificado)
            //, new SqlParameter("@descripcion", descripcion)
            //, new SqlParameter("@valorAnterior", valorAnterior)
            //, new SqlParameter("@valorActual", valorActual)
            //, new SqlParameter("@usuario", usuario)
            //, new SqlParameter("@objetoId", objetoId));
        }
Ejemplo n.º 7
0
        public List <ResponsableDto> createResponsable(ResponsableDto Responsable)
        {
            List <ResponsableDto> lista = new List <ResponsableDto>();
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(Responsable);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "RESPONSABLE", "Se ha creado el Responsable", null, Responsable.Nombre + ' ' + Responsable.Apellido, usuario, Responsable.Id);
                context.Add(accion);
                context.SaveChanges();
                var sub = context.Responsables.Where(x => x.Id == Responsable.Id).FirstOrDefault();
                lista.Add(sub);
            }
            return(lista);
        }
Ejemplo n.º 8
0
        public List <LocalidadSP> createlocalidad(LocalidadDto localidad)
        {
            var usuario = HttpContext.Current.User.Identity.Name;
            List <LocalidadSP> lista = new List <LocalidadSP>();

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(localidad);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "LOCALIDAD", "Se ha creado una Localidad", null, localidad.Nombre, usuario, localidad.Id);
                context.Add(accion);
                context.SaveChanges();
                return(lista = context.Database
                               .SqlQuery <LocalidadSP>("GetLocalidadesPorId @id", new SqlParameter("@id", localidad.Id))
                               .ToList());
            }
        }
Ejemplo n.º 9
0
        public MediadorDto createMediador(string Nombre)
        {
            var Mediador = new MediadorDto();

            Mediador.Nombre = Nombre.Trim().ToUpper();
            Mediador.Activo = true;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(Mediador);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "MEDIADOR", "Se ha creado el Mediador", null, Mediador.Nombre, usuario, Mediador.Id);
                context.Add(accion);
                context.SaveChanges();
                return(Mediador);
            }
        }
Ejemplo n.º 10
0
        public ServicioDto createServicio(string Nombre)
        {
            var Servicio = new ServicioDto();

            Servicio.Nombre  = Nombre.Trim().ToUpper();
            Servicio.Deleted = false;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(Servicio);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "SERVICIO", "Se ha creado el Servicio", null, Servicio.Nombre, usuario, Servicio.Id);
                context.Add(accion);
                context.SaveChanges();
                return(Servicio);
            }
        }
Ejemplo n.º 11
0
        public RegionDto createRegion(string Nombre)
        {
            var Region = new RegionDto();

            Region.Nombre  = Nombre.ToUpper();
            Region.Deleted = false;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(Region);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "REGION", "Se ha creado la Región", null, Region.Nombre, usuario, Region.Id);
                context.Add(accion);
                context.SaveChanges();
                return(Region);
            }
        }
        public List <MotivoDeReclamoSP> createMotivoDeReclamo(MotivoDeReclamoDto MotivoDeReclamo)
        {
            List <MotivoDeReclamoSP> lista = new List <MotivoDeReclamoSP>();
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(MotivoDeReclamo);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "MOTIVO DE RECLAMO", "Se ha creado el MotivoDeReclamo", null, MotivoDeReclamo.Nombre, usuario, MotivoDeReclamo.Id);
                context.Add(accion);
                context.SaveChanges();
                lista = context.Database
                        .SqlQuery <MotivoDeReclamoSP>("GetMotivosDeReclamoPorId @motivoId", new SqlParameter("@motivoId", MotivoDeReclamo.Id))
                        .ToList();
            }
            return(lista);
        }
Ejemplo n.º 13
0
        public MotivoDeBajaDto createMotivo(string Nombre)
        {
            var motivo = new MotivoDeBajaDto();

            motivo.Nombre  = Nombre.ToUpper();
            motivo.Deleted = false;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(motivo);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "MOTIVO DE BAJA", "Se ha creado el Motivo de Baja", null, motivo.Nombre, usuario, motivo.Id);
                context.Add(accion);
                context.SaveChanges();
                return(motivo);
            }
        }
Ejemplo n.º 14
0
        public ProvinciaDto createProvincia(string Nombre)
        {
            var provincia = new ProvinciaDto();

            provincia.Nombre  = Nombre.Trim().ToUpper();
            provincia.Deleted = false;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(provincia);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "PROVINCIA", "Se ha creado la PROVINCIA", null, provincia.Nombre, usuario, provincia.Id);
                context.Add(accion);
                context.SaveChanges();
                return(provincia);
            }
        }
Ejemplo n.º 15
0
        public TipoEventoDto createTipoEvento(string Nombre, bool esAgendable)
        {
            var TipoEvento = new TipoEventoDto();

            TipoEvento.Nombre    = Nombre.Trim().ToUpper();
            TipoEvento.Agendable = esAgendable;
            TipoEvento.Deleted   = false;
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(TipoEvento);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "TIPO EVENTO", "Se ha creado el de Tipo de Evento", null, TipoEvento.Nombre, usuario, TipoEvento.Id);
                context.Add(accion);
                context.SaveChanges();
                return(TipoEvento);
            }
        }
Ejemplo n.º 16
0
 public void createEvento(EventoDto evento, int?idRes)
 {
     using (NuevoDbContext context = new NuevoDbContext())
     {
         var usuario = context.Responsables.Where(x => x.Id == idRes).FirstOrDefault();
         evento.CREATIONPERSON = usuario.UmeId;
         evento.Deleted        = false;
         context.Add(evento);
         context.SaveChanges();
     }
 }
Ejemplo n.º 17
0
        public List <DomicilioMediadorSP> createDomicilioMediador(DomicilioMediadorDto DomicilioMediador)

        {
            List <DomicilioMediadorSP> lista = new List <DomicilioMediadorSP>();
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(DomicilioMediador);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "DOMICILIO MEDIADOR", "Se ha creado el Domicilio del Mediador", null, DomicilioMediador.Domicilio, usuario, DomicilioMediador.Id);
                context.Add(accion);
                context.SaveChanges();

                lista = context.Database
                        .SqlQuery <DomicilioMediadorSP>("GetDomicilioMediadorPorId @id", new SqlParameter("@id", DomicilioMediador.Id))
                        .ToList();
            }
            return(lista);
        }
Ejemplo n.º 18
0
        public List <SubEstadoSP> createSubEstado(SubEstadoDto SubEstado)
        //public List<SubEstadoDto> createSubEstado(SubEstadoDto SubEstado)
        {
            List <SubEstadoSP> lista = new List <SubEstadoSP>();
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(SubEstado);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "SUB ESTADO", "Se ha creado el SubEstado", null, SubEstado.Nombre, usuario, SubEstado.Id);
                context.Add(accion);
                context.SaveChanges();
                //var sub = context.SubEstados.Where(x => x.Id == SubEstado.Id).FirstOrDefault();
                //lista.Add(sub);
                lista = context.Database
                        .SqlQuery <SubEstadoSP>("GetSubEstadosPorId @motivoId", new SqlParameter("@motivoId", SubEstado.Id))
                        .ToList();
            }
            return(lista);
        }
Ejemplo n.º 19
0
        public ReclamoDto crearReclamo(int?motivoReclamoId)
        {
            ReclamoDto reclamo = new ReclamoDto();

            reclamo.Id_Motivo_Reclamo = motivoReclamoId;
            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(reclamo);
                context.SaveChanges();
                return(reclamo);
            }
        }
Ejemplo n.º 20
0
        public ExpedienteDto crearExpediente(string unExpediente)
        {
            ExpedienteDto expedienteDto = new ExpedienteDto();

            expedienteDto.Numero = unExpediente;
            using (NuevoDbContext context = new NuevoDbContext())
            {
                context.Add(expedienteDto);
                context.SaveChanges();
                return(expedienteDto);
            }
        }
Ejemplo n.º 21
0
 public int?createDenunciante(DenuncianteDto test)
 {
     using (NuevoDbContext context = new NuevoDbContext())
     {
         if (!existeDenunciante(test, context))
         {
             context.Add(test);
             context.SaveChanges();
             return(test.DenuncianteId);
             //return context.Denunciantes.ToList().Where(d => d.DenuncianteId == test.DenuncianteId).Single() ;
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 22
0
        //[HttpGet]
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult DescargarArchivo(Guid id)
        {
            ArchivoDto        _ArchivoDto;
            FileContentResult _fileContent;

            using (_dbContext = new NuevoDbContext())
            {
                _ArchivoDto = _dbContext.Archivos.FirstOrDefault(x => x.Id == id);
            }

            if (_ArchivoDto == null)
            {
                return(HttpNotFound());
            }
            else
            {
                try
                {
                    // Descargamos el ArchivoDto del Servidor.
                    _fileContent = new FileContentResult(_ArchivoDto.DescargarArchivo(),
                                                         "application/octet-stream");
                    _fileContent.FileDownloadName = _ArchivoDto.Nombre + "." + _ArchivoDto.Extension;

                    // Actualizamos el nº de descargas en la base de datos.
                    using (_dbContext = new NuevoDbContext())
                    {
                        _ArchivoDto.Descargas++;
                        _dbContext.Archivos.Attach(_ArchivoDto);
                        _dbContext.Entry(_ArchivoDto).State = EntityState.Modified;
                        _dbContext.SaveChanges();

                        var usuario = System.Web.HttpContext.Current.User.Identity.Name;
                        var logger  = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIA", "Descarga de Archivo", _ArchivoDto.Nombre + '.' + _ArchivoDto.Extension, _ArchivoDto.path, usuario, (int)Session["DenunciaActual"]);
                        _dbContext.Add(logger);
                        _dbContext.SaveChanges();
                    }

                    return(_fileContent);
                }
                catch (Exception ex)
                {
                    return(HttpNotFound());
                }
            }
        }
Ejemplo n.º 23
0
        public void deleteDenunciante(DenuncianteDto denuncianteDto)
        {
            var usuario = HttpContext.Current.User.Identity.Name;

            using (NuevoDbContext context = new NuevoDbContext())
            {
                //load task from database
                DenuncianteDto existingTest = context.getDenunciantes(true)
                                              .Where(t => t.DenuncianteId == denuncianteDto.DenuncianteId)
                                              .FirstOrDefault();

                context.Remove(existingTest);
                context.SaveChanges();
                var accion = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIANTE", "Se ha eliminado al Denunciante", "Denunciante : " + denuncianteDto.apellido + "," + denuncianteDto.nombre + "," + " dni: " + denuncianteDto.NroDocumento, "ELIMINADO", usuario, denuncianteDto.DenuncianteId);
                context.Add(accion);
                context.SaveChanges();
            }
        }
Ejemplo n.º 24
0
        public List <string> GetUserRoles(string user, string aplication, string system)
        {
            string        error      = "";
            List <string> listResult = new List <string>();

            try
            {
                string     app        = "*";
                string     sys        = system;
                LdapServer ldapServer = new LdapServer(SetDataConfiguration());
                listResult = ldapServer.GetUserRoles(user, app, sys);

                //var itenes = "No trajo ningún DnRol";
                //foreach (var item in listResult) {
                //    itenes = item + " <--> ";
                //}
                //using (NuevoDbContext db = new NuevoDbContext())
                //{
                //    var log = new LogErrorDto();
                //    log.Fecha = DateTime.Now;
                //    log.Error = itenes;
                //    log.UserId = user;
                //    //log.ErrorDetallado = itenes;
                //    db.Add(log);
                //    db.SaveChanges();
                //}
            }
            catch (Exception ex)
            {
                error = ex.Message;
                using (NuevoDbContext db = new NuevoDbContext())
                {
                    var log = new LogErrorDto();
                    log.Fecha = DateTime.Now;
                    log.Error = error;
                    db.Add(log);
                    db.SaveChanges();
                }
            }
            return(listResult);
        }
Ejemplo n.º 25
0
        public ActionResult EliminarArchivo(string id)
        {
            ArchivoDto _ArchivoDto;

            var idDelete = new Guid(id);

            using (_dbContext = new NuevoDbContext())
            {
                _ArchivoDto = _dbContext.Archivos.FirstOrDefault(x => x.Id == idDelete);
            }

            if (_ArchivoDto != null)
            {
                using (_dbContext = new NuevoDbContext())
                {
                    _ArchivoDto = _dbContext.Archivos.FirstOrDefault(x => x.Id == idDelete);
                    var archivoEliminado = _ArchivoDto;
                    _dbContext.Archivos.Remove(_ArchivoDto);
                    if (_dbContext.SaveChanges() > 0)
                    {
                        // Eliminamos el ArchivoDto del Servidor.
                        _ArchivoDto.EliminarArchivo();
                        var usuario = System.Web.HttpContext.Current.User.Identity.Name;
                        var logger  = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIA", "Archivo Eliminado", archivoEliminado.Nombre + '.' + archivoEliminado.Extension, archivoEliminado.path, usuario, (int)Session["DenunciaActual"]);
                        _dbContext.Add(logger);
                        _dbContext.SaveChanges();
                    }
                }
                // Redirigimos a la Acción 'Index' para mostrar
                // Los Archivos subidos al Servidor.
                return(Json("Registro eliminado con éxito", JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index");
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 26
0
        protected void Application_Error()
        {
            Exception   ex   = this.Server.GetLastError();
            var         url  = Request.Url.ToString();
            var         user = HttpContext.Current.User.Identity.Name;
            ErrorLogger log  = new ErrorLogger(ex, url, user);

            using (NuevoDbContext context = new NuevoDbContext()) {
                var e = new LogErrorDto();
                e.Fecha = DateTime.Now;
                e.Error = ex.Message;
                //if (ex.) {
                //    var errorMessages = ex.EntityValidationErrors
                //        .SelectMany(x => x.ValidationErrors)
                //        .Select(x => x.ErrorMessage);
                //}
                e.UrlRequest     = url;
                e.UserId         = user;
                e.ErrorDetallado = ex.ToString();
                context.Add(e);
                context.SaveChanges();
            }
        }
Ejemplo n.º 27
0
        public bool LoginUser(string user, string pwd)
        {
            bool   result = false;
            string data   = "";

            try
            {
                LdapServer ldapServer = new LdapServer(SetDataConfiguration());
                result = ldapServer.AuthenticateUser(user, pwd);
            }
            catch (Exception ex)
            {
                data = ex.Message;
                using (NuevoDbContext db = new NuevoDbContext())
                {
                    var log = new LogErrorDto();
                    log.Fecha = DateTime.Now;
                    log.Error = data;
                    db.Add(log);
                    db.SaveChanges();
                }
            }
            return(result);
        }
Ejemplo n.º 28
0
        public ActionResult uploadFile(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var _contenido = new byte[file.ContentLength];
                file.InputStream.Read(_contenido, 0, file.ContentLength);

                int    indiceDelUltimoPunto = file.FileName.LastIndexOf('.');
                string _nombre    = file.FileName.Substring(0, indiceDelUltimoPunto);
                string _extension = file.FileName.Substring(indiceDelUltimoPunto + 1,
                                                            file.FileName.Length - indiceDelUltimoPunto - 1);

                ArchivoDto _ArchivoDto = new ArchivoDto()
                {
                    Nombre     = _nombre,
                    Extension  = _extension,
                    Descargas  = 0,
                    DenunciaId = (int)Session["DenunciaActual"]
                };

                var carpetaActual = (string)Session["CarpetaActual"];

                _ArchivoDto.PathRelativo(carpetaActual);
                _ArchivoDto.SubirArchivo(_contenido);

                using (_dbContext = new NuevoDbContext())
                {
                    try {
                        var usuario = System.Web.HttpContext.Current.User.Identity.Name;
                        _ArchivoDto.usuarioCreador = usuario;
                        var archivoNuevo = _ArchivoDto;
                        _dbContext.Archivos.Add(_ArchivoDto);
                        _dbContext.SaveChanges();

                        var logger = new CommonChangeLoggerDto(DateTime.Now, "DENUNCIA", "Archivo Creado", archivoNuevo.Nombre + '.' + archivoNuevo.Extension, archivoNuevo.path, usuario, (int)Session["DenunciaActual"]);
                        _dbContext.Add(logger);
                        _dbContext.SaveChanges();
                    }
                    catch (DbEntityValidationException ex) {
                        var errorMessages = ex.EntityValidationErrors
                                            .SelectMany(x => x.ValidationErrors)
                                            .Select(x => x.ErrorMessage);
                        var fullErrorMessage = string.Join("; ", errorMessages);

                        var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                        throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
                    }
                }
            }

            var id = (int)Session["DenunciaActual"];

            using (_dbContext = new NuevoDbContext())
            {
                var Archivos = _dbContext.Archivos.Where(x => x.DenunciaId == id).OrderByDescending(x => x.fechaCreacion).ToList();
                return(PartialView("FileList", Archivos));
            }


            // Redirigimos a la Acción 'Index' para mostrar
            // Los Archivos subidos al Servidor.
        }
Ejemplo n.º 29
0
        public async Task <ActionResult> validarListaDni(List <List <string> > documentosAValidar)
        {
            var dniExistentes = new List <List <string> >();

            List <DenuncianteDto> denunciantes = new List <DenuncianteDto>();
            var     grupo   = new GrupoDto();
            GrupoSP grupoSP = new GrupoSP();

            using (NuevoDbContext context = new NuevoDbContext())
            {
                foreach (var item in documentosAValidar)
                {
                    DenuncianteDto nuevoDenunciante = new DenuncianteDto();

                    if (String.IsNullOrEmpty(item[4]))
                    {
                        nuevoDenunciante.nombre       = item[1].ToUpper();
                        nuevoDenunciante.apellido     = item[2].ToUpper();
                        nuevoDenunciante.NroDocumento = item[3];

                        var denuncianteExistente = await context.Denunciantes.Where(d => String.Equals(d.NroDocumento.Trim(), nuevoDenunciante.NroDocumento.Trim()) &&
                                                                                    String.Equals(d.nombre.Trim(), nuevoDenunciante.nombre.Trim()) &&
                                                                                    String.Equals(d.apellido.Trim(), nuevoDenunciante.apellido.Trim()))
                                                   .FirstOrDefaultAsync();

                        if (denuncianteExistente == null)
                        {
                            context.Add(nuevoDenunciante);
                            await context.SaveChangesAsync();

                            denunciantes.Add(nuevoDenunciante);
                        }
                        else
                        {
                            denunciantes.Add(denuncianteExistente);
                        }
                    }
                    else
                    {
                        var idExistente = Convert.ToInt32(item[4]);
                        nuevoDenunciante = await context.Denunciantes.Where(d => d.DenuncianteId == idExistente).FirstOrDefaultAsync();

                        denunciantes.Add(nuevoDenunciante);
                    }
                    //denunciantes.Add(nuevoDenunciante);
                }


                //grupo.grupoDenunciantes = denunciantes; comentado 12/05/2020
                grupo.IdDenunciantePrincipal = denunciantes[0].DenuncianteId;
                context.Add(grupo);
                await context.SaveChangesAsync();

                //agregado 12/05/2020
                var idGrupo = grupo.Id;
                foreach (var item in denunciantes)
                {
                    var fechaCreacion = DateTime.Now;
                    context.Database
                    .ExecuteSqlCommand("Insert into GrupoDenunciantesRel values(@GrupoDto_Id,@DenuncianteId,@fechaCreacion)"
                                       , new SqlParameter("@GrupoDto_Id", idGrupo)
                                       , new SqlParameter("@DenuncianteId", item.DenuncianteId)
                                       , new SqlParameter("@fechaCreacion", fechaCreacion));
                }
                List <DenuncianteGrupoSP> grupoDenunciantes = context.Database
                                                              .SqlQuery <DenuncianteGrupoSP>("GetGrupoDenunciantesPorIdGrupo @grupoId", new SqlParameter("@grupoId", idGrupo))
                                                              .ToList();

                grupoSP.Id = grupoDenunciantes.First().GrupoDto_Id;
                grupoSP.grupoDenunciantes = grupoDenunciantes;

                // auditoria

                var fechaCreacionGrupoAuditoria = DateTime.Now;
                var objetoModificado            = "GRUPO";
                var descripcionObjeto           = "Se ha creado al grupoId : " + grupoSP.Id.ToString();
                var valorAnterior = "";
                var valorActual   = "Cantidad de Integrantes : " + grupoSP.grupoDenunciantes.Count.ToString();
                var usuario       = System.Web.HttpContext.Current.User.Identity.Name;

                context.Database
                .ExecuteSqlCommand("Insert into tCommonChLogger values(@fechaCreacionGrupo,@objetoModificado,@descripcionObjeto,@valorAnterior,@valorActual,@usuario,@GrupoDto_Id)"
                                   , new SqlParameter("@fechaCreacionGrupo", fechaCreacionGrupoAuditoria)
                                   , new SqlParameter("@objetoModificado", objetoModificado)
                                   , new SqlParameter("@descripcionObjeto", descripcionObjeto)
                                   , new SqlParameter("@valorAnterior", valorAnterior)
                                   , new SqlParameter("@valorActual", valorActual)
                                   , new SqlParameter("@usuario", usuario)
                                   , new SqlParameter("@GrupoDto_Id", grupoSP.Id));
            }
            return(PartialView("ListGrupoDenunciantesSP", grupoSP));
            //return PartialView("ListGrupoDenunciantes", grupo);
        }
Ejemplo n.º 30
0
        public async Task <ActionResult> AgregarNuevosDenunciantes(List <List <string> > lista, int idGrupo)
        {
            var dniExistentes = new List <List <string> >();

            List <DenuncianteDto> denunciantes = new List <DenuncianteDto>();
            var grupo = new GrupoDto();

            using (NuevoDbContext context = new NuevoDbContext())
            {
                foreach (var item in lista)
                {
                    DenuncianteDto nuevoDenunciante = new DenuncianteDto();

                    if (String.IsNullOrEmpty(item[4]))
                    {
                        nuevoDenunciante.nombre       = item[1].ToUpper();
                        nuevoDenunciante.apellido     = item[2].ToUpper();
                        nuevoDenunciante.NroDocumento = item[3];

                        var denuncianteExistente = await context.Denunciantes.Where(d => String.Equals(d.NroDocumento.Trim(), nuevoDenunciante.NroDocumento.Trim()) &&
                                                                                    String.Equals(d.nombre.Trim(), nuevoDenunciante.nombre.Trim()) &&
                                                                                    String.Equals(d.apellido.Trim(), nuevoDenunciante.apellido.Trim()))
                                                   .FirstOrDefaultAsync();

                        if (denuncianteExistente == null)
                        {
                            context.Add(nuevoDenunciante);
                            await context.SaveChangesAsync();

                            denunciantes.Add(nuevoDenunciante);
                        }
                        else
                        {
                            denunciantes.Add(denuncianteExistente);
                        }
                    }
                    else
                    {
                        var idExistente = Convert.ToInt32(item[4]);
                        nuevoDenunciante = await context.Denunciantes.Where(d => d.DenuncianteId == idExistente).FirstOrDefaultAsync();

                        denunciantes.Add(nuevoDenunciante);
                    }
                }

                foreach (var item in denunciantes)
                {
                    var fechaCreacion = DateTime.Now;
                    context.Database
                    .ExecuteSqlCommand("Insert into GrupoDenunciantesRel values(@GrupoDto_Id,@DenuncianteId,@fechaCreacion)"
                                       , new SqlParameter("@GrupoDto_Id", idGrupo)
                                       , new SqlParameter("@DenuncianteId", item.DenuncianteId)
                                       , new SqlParameter("@fechaCreacion", fechaCreacion));
                }

                //auditoria
                foreach (var item in denunciantes)
                {
                    var fechaCreacionGrupoAuditoria = DateTime.Now;
                    var objetoModificado            = "GRUPO";
                    var descripcionObjeto           = "Se agregó al Denunciante con Id : " + item.DenuncianteId + " al grupo Id : " + idGrupo.ToString();
                    var valorAnterior = "";
                    var valorActual   = "";
                    var usuario       = System.Web.HttpContext.Current.User.Identity.Name;

                    context.Database
                    .ExecuteSqlCommand("Insert into tCommonChLogger values(@fechaCreacionGrupo,@objetoModificado,@descripcionObjeto,@valorAnterior,@valorActual,@usuario,@GrupoDto_Id)"
                                       , new SqlParameter("@fechaCreacionGrupo", fechaCreacionGrupoAuditoria)
                                       , new SqlParameter("@objetoModificado", objetoModificado)
                                       , new SqlParameter("@descripcionObjeto", descripcionObjeto)
                                       , new SqlParameter("@valorAnterior", valorAnterior)
                                       , new SqlParameter("@valorActual", valorActual)
                                       , new SqlParameter("@usuario", usuario)
                                       , new SqlParameter("@GrupoDto_Id", idGrupo));
                }
            }
            return(RedirectToAction("TraerGrupoDenunciantes", "Denunciantes", new { grupoId = idGrupo }));
        }