Exemplo n.º 1
0
        public async Task <ActionResult> BuscarListAgendaExternos([Bind(Include = "fechaDesde,fechaHasta,soloFechas,estudioSeleccionado,organismoSeleccionado,tipoEventoSeleccionado,reqInformeSeleccionado,solucionadoSeleccionado,provinciaSeleccionada,responsableSeleccionado,idDenuncia,dniDenunciante,contestado,CurrentPageIndex,PageCount,filtrarPorFechaVencimiento,filtrarPorFechaDenuncia,filtrarPorFechaNotificacion,filtrarPorFechaNotificacionGcia,esUnCambioMasivo")] AgendaModelView model)
        {
            int             maxRows         = 30;
            List <AgendaSP> lista           = new List <AgendaSP>();
            var             fechaDesde      = model.fechaDesde;
            var             fechaHasta      = model.fechaHasta;
            PaginadorAgenda paginadorAgenda = new PaginadorAgenda();

            using (var context = new NuevoDbContext())
            {
                if (model.filtrarPorFechaVencimiento)
                {
                    lista = await context.Database
                            .SqlQuery <AgendaSP>("GetListAgenda @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToListAsync();

                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.Fecha).ToList();
                }

                else
                if (model.filtrarPorFechaNotificacion)
                {
                    lista = await context.Database
                            .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacion @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToListAsync();

                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.DenunciaId).ToList();
                }
                else
                if (model.filtrarPorFechaNotificacionGcia)
                {
                    lista = await context.Database
                            .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionGcia @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToListAsync();

                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.DenunciaId).ToList();
                }
                if (model.tipoEventoSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.TipoEventoId == model.tipoEventoSeleccionado).ToList();
                }
                //if (model.organismoSeleccionado > 0/*!= null*/)
                //{
                //    lista = lista.Where(e => e.OrganismoId == model.organismoSeleccionado).ToList();
                //}
                if (model.reqInformeSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.ReqInformeId == model.reqInformeSeleccionado).ToList();
                }
                //if (model.solucionadoSeleccionado > 0/*!= null*/)
                //{
                //    lista = lista.Where(e => e.SolucionadoId == model.solucionadoSeleccionado).ToList();
                //}
                //if (model.estudioSeleccionado > 0/*!= null*/)
                //{
                //    lista = lista.Where(e => e.estudioId == model.estudioSeleccionado).ToList();
                //}
                //if (model.provinciaSeleccionada > 0/*!= null*/)
                //{
                //    lista = lista.Where(e => e.ProvinciaId == model.provinciaSeleccionada).ToList();
                //}
                //if (model.responsableSeleccionado > 0)
                //{
                //    lista = lista.Where(e => e.ResIntId == model.responsableSeleccionado).ToList();
                //}
                //if (model.idDenuncia != null)
                //{
                //    lista = lista.Where(e => e.DenunciaId == model.idDenuncia).ToList();
                //}
                //if (!String.IsNullOrWhiteSpace(model.dniDenunciante))
                //{

                //    lista = lista.Where(e => String.Equals(e.dniDenunciante, model.dniDenunciante)).ToList();
                //}
                //if (model.contestado)
                //{
                //    lista = lista.Where(e => e.Contestado == 1).ToList();
                //}

                //if (String.Equals((string)Session["userRol"], "Estudio Externo"))
                //{
                var estudioIdSession = (int?)Session["estudioExternoId"];
                if (estudioIdSession != null)
                {
                    var estudioId = (int)Session["estudioExternoId"];
                    lista = lista.Where(x => x.estudioId == estudioId).ToList();
                }
                else
                {
                    return(PartialView("ExternoSinEstudio"));
                }

                //}

                paginadorAgenda.listadoAgenda = lista
                                                .Skip((model.CurrentPageIndex - 1) * maxRows)
                                                .Take(maxRows).ToList();
                paginadorAgenda.totalDeRegistros = lista.Count();
            }
            double pageCount = (double)((decimal)lista.Count() / Convert.ToDecimal(maxRows));

            paginadorAgenda.PageCount = (int)Math.Ceiling(pageCount);

            paginadorAgenda.CurrentPageIndex = model.CurrentPageIndex;


            return(PartialView("ListAgendaPaginadaExternos", paginadorAgenda));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> BuscarListAgenda([Bind(Include = "fechaDesde,fechaHasta,soloFechas,estudioSeleccionado,organismoSeleccionado,tipoEventoSeleccionado,reqInformeSeleccionado,solucionadoSeleccionado,provinciaSeleccionada,responsableSeleccionado,idDenuncia,dniDenunciante,contestado,CurrentPageIndex,PageCount,filtrarPorFechaVencimiento,filtrarPorFechaDenuncia,filtrarPorFechaNotificacion,filtrarPorFechaNotificacionGcia,esUnCambioMasivo")] AgendaModelView model)

        {
            int             maxRows         = 30;
            List <AgendaSP> lista           = new List <AgendaSP>();
            var             fechaDesde      = model.fechaDesde;
            var             fechaHasta      = model.fechaHasta;
            PaginadorAgenda paginadorAgenda = new PaginadorAgenda();

            using (var context = new NuevoDbContext())
            {
                if (model.filtrarPorFechaVencimiento)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetListAgendaDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToListAsync();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetListAgendaHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }
                    else
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetListAgenda @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }
                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.Fecha).ToList();
                }

                else
                if (model.filtrarPorFechaNotificacion)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToListAsync();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }
                    else
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacion @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }


                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.DenunciaId).ToList();
                }
                else
                if (model.filtrarPorFechaNotificacionGcia)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionGciaDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToListAsync();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionGciaHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }
                    else
                    {
                        lista = await context.Database
                                .SqlQuery <AgendaSP>("GetEventosPorFechasNotificacionGcia @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToListAsync();
                    }
                    lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.DenunciaId).ToList();
                }
                if (model.tipoEventoSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.TipoEventoId == model.tipoEventoSeleccionado).ToList();
                }
                if (model.organismoSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.OrganismoId == model.organismoSeleccionado).ToList();
                }
                if (model.reqInformeSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.ReqInformeId == model.reqInformeSeleccionado).ToList();
                }
                if (model.solucionadoSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.SolucionadoId == model.solucionadoSeleccionado).ToList();
                }
                if (model.estudioSeleccionado > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.estudioId == model.estudioSeleccionado).ToList();
                }
                if (model.provinciaSeleccionada > 0 /*!= null*/)
                {
                    lista = lista.Where(e => e.ProvinciaId == model.provinciaSeleccionada).ToList();
                }
                if (model.responsableSeleccionado > 0)
                {
                    lista = lista.Where(e => e.ResIntId == model.responsableSeleccionado).ToList();
                }
                if (model.idDenuncia != null)
                {
                    lista = lista.Where(e => e.DenunciaId == model.idDenuncia).ToList();
                }
                if (!String.IsNullOrWhiteSpace(model.dniDenunciante))
                {
                    //ICollection<object> bools= new List<object>();
                    //foreach (var item in lista) {
                    //    var x = (item.dniDenunciante.Equals(model.dniDenunciante));
                    //    bools.Add(x);
                    //}

                    //lista = lista.Where(e => String.Equals(e.dniDenunciante.Trim(), model.dniDenunciante.Trim())).ToList();

                    lista = lista.Where(e => !String.IsNullOrEmpty(e.dniDenunciante)).ToList();
                    lista = lista.Where(e => e.dniDenunciante.Trim().ToUpper().Contains(model.dniDenunciante.Trim().ToUpper())).ToList();
                }
                if (model.contestado)
                {
                    lista = lista.Where(e => e.Contestado == 1).ToList();
                }
                if (model.esUnCambioMasivo)
                {
                    return(PartialView("ListAgendaMM", lista));
                }



                paginadorAgenda.listadoAgenda = lista
                                                .Skip((model.CurrentPageIndex - 1) * maxRows)
                                                .Take(maxRows).ToList();
                paginadorAgenda.totalDeRegistros = lista.Count();
            }
            double pageCount = (double)((decimal)lista.Count() / Convert.ToDecimal(maxRows));

            paginadorAgenda.PageCount = (int)Math.Ceiling(pageCount);

            paginadorAgenda.CurrentPageIndex = model.CurrentPageIndex;


            return(PartialView("ListAgendaPaginada", paginadorAgenda));
        }