public async Task <IEnumerable <HdDocVM> > GetAllVM(HdDocFiltro filtro) { try { int iconsultor = (filtro.consultor_id == 0) ? 0 : 1; int iprogramador = (filtro.programador_id == 0) ? 0 : 1; int icia = (filtro.cia_id == 0) ? 0 : 1; int i178 = (filtro.aplicacion_178_id == 0) ? 0 : 1; int i170 = (filtro.urgencia_170_id == 0) ? 0 : 1; int i172 = (filtro.tipo_172_id == 0) ? 0 : 1; int i175 = (filtro.status_175_id == 0) ? 0 : 1; int i214 = (filtro.modulo_214_id == 0) ? 0 : 1; int i298 = (filtro.motivo_298_id == 0) ? 0 : 1; int ipais = (filtro.pais_id == 0) ? 0 : 1; int inumero = (filtro.numero == 0) ? 0 : 1; int ititulo = (filtro.titulo.EsNulaOVacia()) ? 0 : 1; int idescri = (filtro.descripcion.EsNulaOVacia()) ? 0 : 1; filtro.consultor_id = (iconsultor == 0) ? -1 : filtro.consultor_id; filtro.programador_id = (iprogramador == 0) ? -1 : filtro.programador_id; filtro.cia_id = (icia == 0) ? -1 : filtro.cia_id; filtro.aplicacion_178_id = (i178 == 0) ? -1 : filtro.aplicacion_178_id; filtro.urgencia_170_id = (i170 == 0) ? -1 : filtro.urgencia_170_id; filtro.tipo_172_id = (i172 == 0) ? -1 : filtro.tipo_172_id; filtro.status_175_id = (i175 == 0) ? -1 : filtro.status_175_id; filtro.motivo_298_id = (i298 == 0) ? -1 : filtro.motivo_298_id; filtro.modulo_214_id = (i214 == 0) ? -1 : filtro.modulo_214_id; filtro.pais_id = (ipais == 0) ? -1 : filtro.pais_id; filtro.numero = (inumero == 0) ? -1 : filtro.numero; filtro.titulo = (ititulo == 0) ? filtro.titulo : filtro.titulo.Trim().ToLower(); filtro.descripcion = (idescri == 0) ? filtro.descripcion : filtro.descripcion.Trim().ToLower(); int ileidoc = (filtro.leido_consultor == -1) ? 0 : 1; int ileidop = (filtro.leido_programador == -1) ? 0 : 1; bool bleidoc = false; bool bleidop = false; if (filtro.leido_consultor == 1) { bleidoc = true; } if (filtro.leido_programador == 1) { bleidop = true; } if (ititulo == 1) { filtro.titulo = filtro.titulo.ToLower(); } if (idescri == 1) { filtro.descripcion = filtro.descripcion.ToLower(); } //(iconsultor == 0) || (iconsultor == 1 && x.consultor_id == filtro.consultor_id) && //(iprogramador == 0) || (iprogramador == 1 && x.programador_id == filtro.programador_id) && //(icia == 0) || (icia == 1 && x.cia_id == filtro.cia_id) && //(i178 == 0) || (i178 == 1 && x.aplicacion_178_id == filtro.aplicacion_178_id) && //(i170 == 0) || (i170 == 1 && x.urgencia_170_id == filtro.urgencia_170_id) && //(i172 == 0) || (i172 == 1 && x.tipo_172_id == filtro.tipo_172_id) && //(i175 == 0) || (i175 == 1 && x.status_175_id == filtro.status_175_id) && //(i214 == 0) || (i214 == 1 && x.modulo_214_id == filtro.modulo_214_id) && //(i298 == 0) || (i298 == 1 && x.motivo_298_id == filtro.motivo_298_id) && //(ipais == 0) || (ipais == 1 && x.pais_id == filtro.pais_id) && //(inumero == 0) || (inumero == 1 && x.numero == filtro.numero) && //(ititulo == 0) || (ititulo == 1 && x.titulo.ToLower().Contains(filtro.titulo)) && //(idescri == 0) || (idescri == 1 && x.descripcion.ToLower().Contains(filtro.descripcion)) && //(ileidoc == 0) || (ileidoc == 1 && x.leido_consultor == bleidoc) && //(ileidop == 0) || (ileidop == 1 && x.leido_programador == bleidop) var docs = await _context.HdDocs .Where(x => ( ((iconsultor == 0) || ((iconsultor == 1) && (x.consultor_id == filtro.consultor_id))) && ((iprogramador == 0) || ((iprogramador == 1) && (x.programador_id == filtro.programador_id))) && ((icia == 0) || ((icia == 1) && (x.cia_id == filtro.cia_id))) && ((i178 == 0) || ((i178 == 1) && (x.aplicacion_178_id == filtro.aplicacion_178_id))) && ((i170 == 0) || ((i170 == 1) && (x.urgencia_170_id == filtro.urgencia_170_id))) && ((i172 == 0) || ((i172 == 1) && (x.tipo_172_id == filtro.tipo_172_id))) && ((i175 == 0) || ((i175 == 1) && (x.status_175_id == filtro.status_175_id))) && ((i214 == 0) || ((i214 == 1) && (x.modulo_214_id == filtro.modulo_214_id))) && ((i298 == 0) || ((i298 == 1) && (x.motivo_298_id == filtro.motivo_298_id))) && ((ititulo == 0) || ((ititulo == 1) && (x.titulo.ToLower().Contains(filtro.titulo)))) && ((idescri == 0) || ((idescri == 1 && x.descripcion.ToLower().Contains(filtro.descripcion)))) && ((ileidoc == 0) || ((ileidoc == 1 && x.leido_consultor == bleidoc))) && ((ileidop == 0) || ((ileidop == 1 && x.leido_programador == bleidop))) ) ).Include(a => a.consultor) .Include(b => b.programador) .Include(c => c.cia) .Include(d => d.aplicacion178) .Include(e => e.urgencia170) .Include(f => f.tipo172) .Include(g => g.status175) .Include(h => h.modulo214) .Include(i => i.motivo298) .Include(j => j.pais) .Select(s => new HdDocVM { hd_doc_id = s.hd_doc_id, consultor_id = s.consultor_id, consultor = s.consultor.nombre, programador_id = s.programador_id, programador = s.programador.nombre, cia_id = s.cia_id, cia = s.cia.nombre, persona_id = s.persona_id, persona = s.persona.nombre_comp, aplicacion_178_id = s.aplicacion_178_id, aplicacion178 = s.aplicacion178.descripcion, urgencia_170_id = s.urgencia_170_id, urgencia170 = s.urgencia170.descripcion, tipo_172_id = s.tipo_172_id, tipo172 = s.tipo172.descripcion, status_175_id = s.status_175_id, status175 = s.status175.descripcion, modulo_214_id = s.modulo_214_id, modulo214 = s.modulo214.descripcion, motivo_298_id = s.motivo_298_id, motivo298 = s.motivo298.descripcion, pais_id = s.pais_id, pais = s.pais.nombre, numero = s.numero, titulo = s.titulo, descripcion = s.descripcion, f_crea = s.f_crea, version_app = s.version_app, version_bd = s.version_bd, f_correccion = s.f_correcion, solucion = s.solucion, version_solucion = s.version_solucion, f_solucionn = s.f_solucion, nombre_contacto = s.nombre_contacto, email_contacto = s.email_contacto, tlf_contacto = s.tlf_contacto, nombre_ventana = s.nombre_ventana, leido_consultor = s.leido_consultor, leido_programador = s.leido_programador }) .ToListAsync(); return(docs); } catch (Exception ex) { throw ex; } }
public async Task <IEnumerable <HdDoc> > GetAll(HdDocFiltro filtro) { try { int iconsultor = (filtro.consultor_id == 0) ? 0 : 1; int iprogramador = (filtro.programador_id == 0) ? 0 : 1; int icia = (filtro.cia_id == 0) ? 0 : 1; int i178 = (filtro.aplicacion_178_id == 0) ? 0 : 1; int i170 = (filtro.urgencia_170_id == 0) ? 0 : 1; int i172 = (filtro.tipo_172_id == 0) ? 0 : 1; int i175 = (filtro.status_175_id == 0) ? 0 : 1; int i214 = (filtro.modulo_214_id == 0) ? 0 : 1; int i298 = (filtro.motivo_298_id == 0) ? 0 : 1; int ipais = (filtro.pais_id == 0) ? 0 : 1; int inumero = (filtro.numero == 0) ? 0 : 1; int ititulo = (filtro.titulo.EsNulaOVacia()) ? 0 : 1; int idescri = (filtro.descripcion.EsNulaOVacia()) ? 0 : 1; filtro.consultor_id = (iconsultor == 0) ? -1 : filtro.consultor_id; filtro.programador_id = (iprogramador == 0) ? -1 : filtro.programador_id; filtro.cia_id = (icia == 0) ? -1 : filtro.cia_id; filtro.aplicacion_178_id = (i178 == 0) ? -1 : filtro.aplicacion_178_id; filtro.urgencia_170_id = (i170 == 0) ? -1 : filtro.urgencia_170_id; filtro.tipo_172_id = (i172 == 0) ? -1 : filtro.tipo_172_id; filtro.status_175_id = (i175 == 0) ? -1 : filtro.status_175_id; filtro.motivo_298_id = (i298 == 0) ? -1 : filtro.motivo_298_id; filtro.modulo_214_id = (i214 == 0) ? -1 : filtro.modulo_214_id; filtro.pais_id = (ipais == 0) ? -1 : filtro.pais_id; filtro.numero = (inumero == 0) ? -1 : filtro.numero; filtro.titulo = (ititulo == 0) ? filtro.titulo : filtro.titulo.Trim().ToLower(); filtro.descripcion = (idescri == 0) ? filtro.descripcion : filtro.descripcion.Trim().ToLower(); int ileidoc = (filtro.leido_consultor == -1) ? 0 : 1; int ileidop = (filtro.leido_programador == -1) ? 0 : 1; bool bleidoc = false; bool bleidop = false; if (filtro.leido_consultor == 1) { bleidoc = true; } if (filtro.leido_programador == 1) { bleidop = true; } if (ititulo == 1) { filtro.titulo = filtro.titulo.ToLower(); } if (idescri == 1) { filtro.descripcion = filtro.descripcion.ToLower(); } var docs = await _context.HdDocs .Where(x => ( ((iconsultor == 0) || ((iconsultor == 1) && (x.consultor_id == filtro.consultor_id))) && ((iprogramador == 0) || ((iprogramador == 1) && (x.programador_id == filtro.programador_id))) && ((icia == 0) || ((icia == 1) && (x.cia_id == filtro.cia_id))) && ((i178 == 0) || ((i178 == 1) && (x.aplicacion_178_id == filtro.aplicacion_178_id))) && ((i170 == 0) || ((i170 == 1) && (x.urgencia_170_id == filtro.urgencia_170_id))) && ((i172 == 0) || ((i172 == 1) && (x.tipo_172_id == filtro.tipo_172_id))) && ((i175 == 0) || ((i175 == 1) && (x.status_175_id == filtro.status_175_id))) && ((i214 == 0) || ((i214 == 1) && (x.modulo_214_id == filtro.modulo_214_id))) && ((i298 == 0) || ((i298 == 1) && (x.motivo_298_id == filtro.motivo_298_id))) && ((ititulo == 0) || ((ititulo == 1) && (x.titulo.ToLower().Contains(filtro.titulo)))) && ((idescri == 0) || ((idescri == 1 && x.descripcion.ToLower().Contains(filtro.descripcion)))) && ((ileidoc == 0) || ((ileidoc == 1 && x.leido_consultor == bleidoc))) && ((ileidop == 0) || ((ileidop == 1 && x.leido_programador == bleidop))) ) ).ToListAsync(); return(docs); } catch (Exception ex) { throw ex; } }