public void deleteDenuncia(DenunciaDto DenunciaDto) { using (NuevoDbContext context = new NuevoDbContext()) { //load task from database DenunciaDto denunciaDto = context.getDenuncias(true) .Where(t => t.DenunciaId == DenunciaDto.DenunciaId) .FirstOrDefault(); context.Remove(denunciaDto); context.SaveChanges(); } }
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); } }
public void EliminarDenuncia(int id, int?motivoBajaId) { using (NuevoDbContext context = new NuevoDbContext()) { //load task from database DenunciaDto denunciaDto = context.getDenuncias(true) .Where(t => t.DenunciaId == id) .FirstOrDefault(); denunciaDto.DELETED = true; denunciaDto.MOTIVOBAJA_ID = motivoBajaId; context.SaveChanges(); this.loguearModificaciones(context, DateTime.Now, "DENUNCIA", "EXISTENTE", "ELIMINADA", "Se ha eliminado la Denuncia", "", id); } }
public ConciliacionHelperClass updateEstadoConciliacion(int?id, int?conciliacionId) { using (NuevoDbContext context = new NuevoDbContext()) { var subestado = context.SubEstados.Where(x => x.Id == conciliacionId).FirstOrDefault(); var helper = new ConciliacionHelperClass(); helper.ConciliacionId = subestado.Id; helper.CierraDenuncia = subestado.CierraDenuncia; DenunciaDto denuncia = context.getDenuncias(true).Where(t => t.DenunciaId == id).FirstOrDefault(); denuncia.CONCILIACION_ID = subestado.Id; //save changes to database context.SaveChanges(); return(helper); } }
private void copyData(DenunciaDto denuncia, DenunciaDto denunciaDto) { denuncia.ETAPA_ID = denunciaDto.ETAPA_ID; denuncia.TIPO_PRO_ID = denunciaDto.TIPO_PRO_ID; denuncia.CREATIONPERSON = denunciaDto.CREATIONPERSON; denuncia.CREATIONDATE = denunciaDto.CREATIONDATE; denuncia.DENUNCIANTE_ID = denunciaDto.DENUNCIANTE_ID; denuncia.TRAMITECRM = denunciaDto.TRAMITECRM; denuncia.OBJETORECLAMO = denunciaDto.OBJETORECLAMO; denuncia.FSELLOCIA = denunciaDto.FSELLOCIA; denuncia.FSELLOGCIADC = denunciaDto.FSELLOGCIADC; denuncia.EXPEDIENTE_ID = denunciaDto.EXPEDIENTE_ID; denuncia.ORGANISMO_ID = denunciaDto.ORGANISMO_ID; denuncia.ESTUDIO_ID = denunciaDto.ESTUDIO_ID; denuncia.MODALIDADGESTION = denunciaDto.MODALIDADGESTION; denuncia.SUBTIPO_PRO_ID = denunciaDto.SUBTIPO_PRO_ID; denuncia.SERV_DEN_ID = denunciaDto.SERV_DEN_ID; denuncia.RECLAMO_ID = denunciaDto.RECLAMO_ID; denuncia.CONCILIACION_ID = denunciaDto.CONCILIACION_ID; denuncia.FECHARESULTADO = denunciaDto.FECHARESULTADO; denuncia.RESP_INT_ID = denunciaDto.RESP_INT_ID; denuncia.grupoId = denunciaDto.grupoId; denuncia.nroClienteContrato = denunciaDto.nroClienteContrato; denuncia.mediadorId = denunciaDto.mediadorId; denuncia.domicilioMediadorId = denunciaDto.domicilioMediadorId; denuncia.reclamoRelacionado = denunciaDto.reclamoRelacionado; //denuncia.idDatosCoprec = denunciaDto.idDatosCoprec; denuncia.fechaHomologacion = denunciaDto.fechaHomologacion; denuncia.nroGestionCoprec = denunciaDto.nroGestionCoprec; denuncia.honorariosCoprec = denunciaDto.honorariosCoprec; denuncia.fechaGestionHonorarios = denunciaDto.fechaGestionHonorarios; denuncia.montoAcordado = denunciaDto.montoAcordado; denuncia.arancel = denunciaDto.arancel; denuncia.fechaGestionArancel = denunciaDto.fechaGestionArancel; denuncia.OBSERVACIONES = denunciaDto.OBSERVACIONES; denuncia.DELETED = denunciaDto.DELETED; denuncia.ECMID = denunciaDto.ECMID; denuncia.agendaCoprec = denunciaDto.agendaCoprec; denuncia.INACTIVO = denunciaDto.INACTIVO; denuncia.PARENTDENUNCIAID = denunciaDto.PARENTDENUNCIAID; }
public DenunciaModelView(int?tipoProcesoId) { var estados = new List <EstadoDto>(); //var estado = new EstadoDto(); var subEstados = new List <SubEstadoDto>(); var tiposProceso = new List <TipoProcesoDto>(); var servicios = new List <ServicioDto>(); var organismos = new List <OrganismoDto>(); var estudios = new List <EstudioDto>(); var tipoEventos = new List <TipoEventoDto>(); var subtipoProcesos = new List <SubTipoProcesoDto>(); var modalidadesDeGestion = new List <ModalidadGestionDto>(); var motivosReclamo = new List <MotivoDeReclamoDto>(); var reqsInforme = new List <ReqInformeDto>(); var mediadores = new List <MediadorDto>(); var domicilios = new List <DomicilioMediadorDto>(); var solucionados = new List <SolucionadoDto>(); var denuncia = new DenunciaDto(); var responsables = new List <ResponsableDto>(); using (NuevoDbContext context = new NuevoDbContext()) { estados = context.Estados.OrderBy(e => e.TipoEstado).ToList(); subEstados = context.SubEstados.Where(s => s.EstadoId == 1 && !s.Deleted).OrderBy(e => e.Nombre).ToList(); tiposProceso = context.TiposDeProceso.OrderBy(e => e.Nombre).ToList(); servicios = context.Servicios.Where(e => !e.Deleted).OrderBy(e => e.Nombre).ToList(); organismos = context.Database.SqlQuery <OrganismoDto>("select * from tOrganismos where Activo=0 order by nombre") .ToList(); estudios = context.Estudios.Where(e => !e.Deleted).OrderBy(e => e.Nombre).ToList(); tipoEventos = context.TiposDeEventos.Where(e => !e.Deleted).OrderBy(e => e.Nombre).ToList(); subtipoProcesos = context.SubTiposDeProceso.Where(e => e.Tipo_Id == tipoProcesoId).OrderBy(e => e.Nombre).ToList(); modalidadesDeGestion = context.ModalidadesDeGestion.OrderBy(e => e.Nombre).ToList(); //motivosReclamo = context.MotivosDeReclamo.Where(e => !e.Deleted).OrderBy(e => e.Nombre).ToList(); reqsInforme = context.ReqsInforme.OrderBy(e => e.Nombre).ToList(); mediadores = context.Mediadores.Where(e => e.Activo).OrderBy(e => e.Nombre).ToList(); domicilios = context.DomiciliosMediadores.Where(e => e.Activo).OrderBy(e => e.Domicilio).ToList(); solucionados = context.Solucionados.OrderBy(e => e.Nombre).ToList(); responsables = context.Responsables.Where(e => !e.Deleted && String.Equals(e.TipoResponsable, "RI")).OrderBy(e => e.Apellido).ToList(); } this.Estados = estados.Select(p => new SelectListItem { Text = p.TipoEstado, Value = p.Id.ToString() /*,Disabled = (p.Nombre != "Conciliación")*/ }); this.SubEstados = subEstados.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.tiposProceso = tiposProceso.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Servicios = servicios.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Organismos = organismos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Estudios = estudios.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.tipoEventos = tipoEventos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.modalidadesDeGestion = modalidadesDeGestion.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.subTiposProceso = subtipoProcesos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.motivosDeReclamo = motivosReclamo.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.reqsInforme = reqsInforme.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.mediadores = mediadores.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.domiciliosMediadores = domicilios.Select(p => new SelectListItem { Text = p.Domicilio, Value = p.Id.ToString() }); this.solucionados = solucionados.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.denuncia = denuncia; this.denuncianteIndividual = denuncia.grupoId == null; this.RESP_INT_ID = denuncia.RESP_INT_ID; this.responsables = responsables.Select(p => new SelectListItem { Text = p.Apellido + ',' + p.Nombre, Value = p.Id.ToString() }); //this.responsables = responsables.Select(p => new SelectListItem { Text = p.Apellido + ',' + p.Nombre + '(' + p.UmeId + ')', Value = p.Id.ToString() }); this.eventos = new List <EventoSP>(); this.evento = new EventoDto(); }
public DenunciaModelView(int?organismoId, int?servicioId, int?etapaProcesalId, int?tipoProcesoId) { var estados = new List <EstadoDto>(); //var estado = new EstadoDto(); var subEstados = new List <SubEstadoDto>(); var tiposProceso = new List <TipoProcesoDto>(); var servicios = new List <ServicioDto>(); var organismos = new List <OrganismoDto>(); var estudios = new List <EstudioDto>(); var tipoEventos = new List <TipoEventoDto>(); var subtipoProcesos = new List <SubTipoProcesoDto>(); var modalidadesDeGestion = new List <ModalidadGestionDto>(); var motivosReclamo = new List <MotivoDeReclamoDto>(); var reqsInforme = new List <ReqInformeDto>(); var mediadores = new List <MediadorDto>(); var domicilios = new List <DomicilioMediadorDto>(); var solucionados = new List <SolucionadoDto>(); var denuncia = new DenunciaDto(); var responsables = new List <ResponsableDto>(); using (NuevoDbContext context = new NuevoDbContext()) { estados = context.Estados.OrderBy(e => e.TipoEstado).ToList(); if (etapaProcesalId != null) { subEstados = context.SubEstados.Where(s => s.EstadoId == etapaProcesalId).OrderBy(e => e.Nombre).ToList(); } else { subEstados = context.SubEstados.Where(s => s.EstadoId == 1).OrderBy(e => e.Nombre).ToList(); //subEstados = context.Database.SqlQuery<string>("select distinct nombre from tSubEstados where Deleted=0 order by nombre") // .ToList(); } tiposProceso = context.TiposDeProceso.OrderBy(e => e.Nombre).ToList(); servicios = context.Servicios.OrderBy(e => e.Nombre).ToList(); organismos = context.Database.SqlQuery <OrganismoDto>("select * from tOrganismos order by nombre") .ToList(); if (organismoId != null) { var estudioIdRelacion = context.Database .SqlQuery <OrganismoEstudioRelSP>("GetOrganismoEstudioRelPorOrganismoId @organismoId", new SqlParameter("@organismoId", organismoId)) .ToList().Select(e => e.EstudioRelacionId); var totalEstudios = context.Estudios.OrderBy(e => e.Nombre).ToList(); foreach (var item in totalEstudios) { if (estudioIdRelacion.Contains(item.Id)) { estudios.Add(item); } } } else { estudios = context.Estudios.OrderBy(e => e.Nombre).ToList(); } nombreOrganismoActual = (organismoId > 0)?context.Organismos.Where(org => org.Id == organismoId).FirstOrDefault().Nombre:""; laDenunciaEsDeCoprec = (nombreOrganismoActual.Contains("COPREC") || nombreOrganismoActual.Contains("Coprec")); tipoEventos = context.TiposDeEventos.Where(e => !e.Deleted).OrderBy(e => e.Nombre).ToList(); subtipoProcesos = context.SubTiposDeProceso.Where(e => e.Tipo_Id == tipoProcesoId).OrderBy(e => e.Nombre).ToList(); modalidadesDeGestion = context.ModalidadesDeGestion.OrderBy(e => e.Nombre).ToList(); if (servicioId != null) { motivosReclamo = context.MotivosDeReclamo.Where(m => m.servicioId == servicioId && m.tipoProcesoId == tipoProcesoId).OrderBy(e => e.Nombre).ToList(); } else { motivosReclamo = context.MotivosDeReclamo.OrderBy(e => e.Nombre).ToList(); } reqsInforme = context.ReqsInforme.OrderBy(e => e.Nombre).ToList(); mediadores = context.Mediadores.OrderBy(e => e.Nombre).ToList(); domicilios = context.DomiciliosMediadores.OrderBy(e => e.Domicilio).ToList(); solucionados = context.Solucionados.OrderBy(e => e.Nombre).ToList(); responsables = context.Responsables.Where(e => String.Equals(e.TipoResponsable, "RI")).OrderBy(e => e.Apellido).ToList(); } this.Estados = estados.Select(p => new SelectListItem { Text = p.TipoEstado, Value = p.Id.ToString() /*,Disabled = (p.Nombre != "Conciliación")*/ }); this.SubEstados = subEstados.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.tiposProceso = tiposProceso.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Servicios = servicios.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Organismos = organismos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.Estudios = estudios.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.tipoEventos = tipoEventos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.modalidadesDeGestion = modalidadesDeGestion.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.subTiposProceso = subtipoProcesos.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.motivosDeReclamo = motivosReclamo.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.reqsInforme = reqsInforme.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.mediadores = mediadores.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.domiciliosMediadores = domicilios.Select(p => new SelectListItem { Text = p.Domicilio, Value = p.Id.ToString() }); this.solucionados = solucionados.Select(p => new SelectListItem { Text = p.Nombre, Value = p.Id.ToString() }); this.denuncia = denuncia; this.denuncianteIndividual = denuncia.grupoId == null; this.RESP_INT_ID = denuncia.RESP_INT_ID; this.responsables = responsables.Select(p => new SelectListItem { Text = p.Apellido + ',' + p.Nombre, Value = p.Id.ToString() }); //this.responsables = responsables.Select(p => new SelectListItem { Text = p.Apellido + ',' + p.Nombre + '(' + p.UmeId + ')', Value = p.Id.ToString() }); this.eventos = new List <EventoSP>(); this.evento = new EventoDto(); }
public int formalizarDenuncia(DenunciaDto preventiva, string usuario) { DenunciaDto nuevaDenuncia = new DenunciaDto(); copyData(nuevaDenuncia, preventiva); using (NuevoDbContext context = new NuevoDbContext()) { nuevaDenuncia.CREATIONDATE = DateTime.Now; nuevaDenuncia.CREATIONPERSON = usuario; nuevaDenuncia.TIPO_PRO_ID = context.TiposDeProceso.Where(x => x.Nombre.Trim() == "DENUNCIA").FirstOrDefault().Id; if (nuevaDenuncia.TIPO_PRO_ID != null) { nuevaDenuncia.SUBTIPO_PRO_ID = context.SubTiposDeProceso.Where(x => x.Tipo_Id == nuevaDenuncia.TIPO_PRO_ID).FirstOrDefault().Id; } ; var nombreMotivoReclamo = ""; if (nuevaDenuncia.RECLAMO_ID.HasValue) { var unReclamo = context.Reclamos.Where(x => x.Id == nuevaDenuncia.RECLAMO_ID.Value).FirstOrDefault(); if (unReclamo != null) { var unMotivo = context.MotivosDeReclamo.Where(x => x.Id == unReclamo.Id_Motivo_Reclamo).FirstOrDefault(); if (unMotivo != null) { nombreMotivoReclamo = unMotivo.Nombre; } } } nuevaDenuncia.FECHARESULTADO = null; nuevaDenuncia.PARENTDENUNCIAID = preventiva.DenunciaId; ReclamoDto nuevoReclamo = new ReclamoDto(); if (context.MotivosDeReclamo.Any(x => x.Nombre.Trim() == nombreMotivoReclamo && x.servicioId == nuevaDenuncia.SERV_DEN_ID && x.tipoProcesoId == nuevaDenuncia.TIPO_PRO_ID)) { var xReclamo = context.MotivosDeReclamo .Where(x => x.Nombre.Trim() == nombreMotivoReclamo && x.servicioId == nuevaDenuncia.SERV_DEN_ID && x.tipoProcesoId == nuevaDenuncia.TIPO_PRO_ID) .FirstOrDefault(); if (xReclamo != null) { nuevoReclamo.Id_Motivo_Reclamo = xReclamo.Id; } } context.Add(nuevoReclamo); context.SaveChanges(); nuevaDenuncia.RECLAMO_ID = nuevoReclamo.Id; //nuevaDenuncia.RECLAMO_ID = context.MotivosDeReclamo // .Where(x =>x.Nombre == nombreMotivoReclamo && // x.servicioId == nuevaDenuncia.SERV_DEN_ID && // x.tipoProcesoId == nuevaDenuncia.TIPO_PRO_ID) // .FirstOrDefault() // .Id; context.Add(nuevaDenuncia); context.SaveChanges(); context.Database.ExecuteSqlCommand("update tDenuncias set PARENTDENUNCIAID = @parentId,INACTIVO = 1 where DenunciaId = @denunciaId", new SqlParameter("@parentId", nuevaDenuncia.DenunciaId), new SqlParameter("@denunciaId", preventiva.DenunciaId)); loguearModificaciones(context, DateTime.Now, "DENUNCIA", "Denuncia Preventiva", "Denuncia Inactiva", "Se ha formalizado la Denuncia", usuario, preventiva.DenunciaId); loguearModificaciones(context, DateTime.Now, "DENUNCIA", "", "", "Se crea la Denuncia " + nuevaDenuncia.DenunciaId.ToString() + " a partir de la Denuncia Preventiva " + preventiva.DenunciaId.ToString(), usuario, nuevaDenuncia.DenunciaId); } return(nuevaDenuncia.DenunciaId); }
public DenunciaDto updateDenuncia(DenunciaDto denunciaDto, string expediente, int?motivoDeReclamoIdDenunciaEditada) { using (NuevoDbContext context = new NuevoDbContext()) { DenunciaDto denuncia = context.getDenuncias(true).Where(t => t.DenunciaId == denunciaDto.DenunciaId).FirstOrDefault(); int?expedienteId = null; int?reclamoDenunciaId = null; if (denuncia != null) { expedienteId = denuncia.EXPEDIENTE_ID; reclamoDenunciaId = denuncia.RECLAMO_ID; } if (expedienteId.HasValue) { var numeroExpedienteExistente = ""; ExpedienteDto expedienteDenuncia = context.Expedientes.Where(unExpediente => unExpediente.Id == denuncia.EXPEDIENTE_ID).FirstOrDefault(); if (expedienteDenuncia != null) { numeroExpedienteExistente = expedienteDenuncia.Numero; } if (expediente != numeroExpedienteExistente) { ExpedienteDto nuevoExpediente = new ExpedienteDto(); nuevoExpediente.Numero = expediente; context.Add(nuevoExpediente); context.SaveChanges(); denunciaDto.EXPEDIENTE_ID = nuevoExpediente.Id; } else { denunciaDto.EXPEDIENTE_ID = expedienteDenuncia.Id; } } else if (expedienteId == null) { if (!String.IsNullOrEmpty(expediente)) { ExpedienteDto nuevoExpediente = new ExpedienteDto(); nuevoExpediente.Numero = expediente; context.Add(nuevoExpediente); context.SaveChanges(); denunciaDto.EXPEDIENTE_ID = nuevoExpediente.Id; } } //if (denuncia.RECLAMO_ID > 0) //if (denuncia.RECLAMO_ID.HasValue) reclamoDenunciaId if (reclamoDenunciaId.HasValue) { var reclamoDenuncia = context.Reclamos.Where(unReclamo => unReclamo.Id == reclamoDenunciaId).FirstOrDefault(); if (reclamoDenuncia.Id_Motivo_Reclamo != motivoDeReclamoIdDenunciaEditada) { ReclamoDto nuevoReclamo = new ReclamoDto(); nuevoReclamo.Id_Motivo_Reclamo = motivoDeReclamoIdDenunciaEditada; context.Add(nuevoReclamo); context.SaveChanges(); denunciaDto.RECLAMO_ID = nuevoReclamo.Id; } else { denunciaDto.RECLAMO_ID = reclamoDenuncia.Id; } } else { if (motivoDeReclamoIdDenunciaEditada.HasValue) { ReclamoDto nuevoReclamo = new ReclamoDto(); nuevoReclamo.Id_Motivo_Reclamo = motivoDeReclamoIdDenunciaEditada; context.Add(nuevoReclamo); context.SaveChanges(); denunciaDto.RECLAMO_ID = nuevoReclamo.Id; } } var usuario = HttpContext.Current.User.Identity.Name; var denChValidator = new DenunciasChangeValidator(denuncia, denunciaDto, usuario); copyData(denuncia, denunciaDto); context.SaveChanges(); denChValidator.registrarCambios(context); return(denuncia); } }