예제 #1
0
        public async Task <ActionResult> GetListAgendaToday([Bind(Include = "fechaDesde,fechaHasta,soloFechas,estudioSeleccionado,organismoSeleccionado,tipoEventoSeleccionado,reqInformeSeleccionado,solucionadoSeleccionado,provinciaSeleccionada,responsableSeleccionado,idDenuncia,dniDenunciante,contestado,CurrentPageIndex,PageCount,filtrarPorFechaVencimiento,filtrarPorFechaDenuncia,filtrarPorFechaNotificacion,filtrarPorFechaNotificacionGcia,esUnCambioMasivo")] AgendaModelView model)
        {
            List <AgendaSP> lista      = new List <AgendaSP>();
            var             fechaDesde = DateTime.Parse(model.fechaDesde);
            var             fechaHasta = DateTime.Parse(model.fechaHasta);
            var             usuario    = System.Web.HttpContext.Current.User.Identity.Name;

            //var fechaDesde = model.fechaDesde;
            //var fechaHasta = model.fechaHasta;
            //var fechaDesdex = DateTime.Parse(model.fechaDesde);
            //var fechaHasta = DateTime.Parse(model.fechaHasta);
            //var horaInicio = "00:00:00";
            //var horaFin = "00:00:00";
            //var fechaDesde = DateTime.Parse(model.fechaDesde.Date.ToString() + ' '+ "00:00:00");
            //var fechaHasta = DateTime.Parse(model.fechaHasta.Date.ToString() + " " + "23:59:59");
            using (var context = new NuevoDbContext())
            {
                int responsableId = context.Responsables.Where(x => x.UmeId == usuario).FirstOrDefault().Id;
                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) & e.ResIntId == responsableId)
                        .OrderBy(e => e.Fecha)
                        .ToList();
            }
            return(PartialView("ListAgendaSP", lista));
        }
예제 #2
0
        private void ExportarListAgenda_old([Bind(Include = "fechaDesde,fechaHasta,soloFechas,estudioSeleccionado,organismoSeleccionado,tipoEventoSeleccionado,reqInformeSeleccionado,solucionadoSeleccionado,provinciaSeleccionada,responsableSeleccionado,idDenuncia,dniDenunciante,contestado,CurrentPageIndex,PageCount,filtrarPorFechaVencimiento,filtrarPorFechaDenuncia,filtrarPorFechaNotificacion,filtrarPorFechaNotificacionGcia,esUnCambioMasivo")] AgendaModelView model)
        {
            List <AgendaExcelSP> lista = new List <AgendaExcelSP>();
            var fechaDesde             = model.fechaDesde;
            var fechaHasta             = model.fechaHasta;

            using (var context = new NuevoDbContext())
            {
                if (model.filtrarPorFechaVencimiento)
                {
                    lista = context.Database
                            .SqlQuery <AgendaExcelSP>("GetAgendaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToList();
                }
                else
                if (model.filtrarPorFechaDenuncia && String.Equals(fechaDesde, fechaHasta))//cambiar fecha en Sp
                {
                    lista = context.Database
                            .SqlQuery <AgendaExcelSP>("GetAgendaPorFechaDenunciaExcel @fecha", new SqlParameter("@fecha", fechaDesde))
                            .ToList();
                }
                else
                if (model.filtrarPorFechaDenuncia && !String.Equals(fechaDesde, fechaHasta))
                {
                    lista = context.Database
                            .SqlQuery <AgendaExcelSP>("GetAgendaPorRangoFechaDenunciaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToList();
                }
                else
                if (model.filtrarPorFechaNotificacion)
                {
                    lista = context.Database
                            .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToList();
                }
                else
                if (model.filtrarPorFechaNotificacionGcia)
                {
                    lista = context.Database
                            .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionGciaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                            .ToList();
                }
                if (model.tipoEventoSeleccionado != null)
                {
                    lista = lista.Where(e => e.TipoEventoId == model.tipoEventoSeleccionado).ToList();
                }
                if (model.organismoSeleccionado != null)
                {
                    lista = lista.Where(e => e.ORGANISMO_ID == model.organismoSeleccionado).ToList();
                }
                if (model.reqInformeSeleccionado != null)
                {
                    lista = lista.Where(e => e.REQUERIMIENTOINFORME == model.reqInformeSeleccionado).ToList();
                }
                if (model.solucionadoSeleccionado != null)
                {
                    lista = lista.Where(e => e.SolucionadoId == model.solucionadoSeleccionado).ToList();
                }
                if (model.estudioSeleccionado != null)
                {
                    lista = lista.Where(e => e.ESTUDIO_ID == model.estudioSeleccionado).ToList();
                }
                if (model.provinciaSeleccionada != null)
                {
                    lista = lista.Where(e => e.Provincia_Id == model.provinciaSeleccionada).ToList();
                }
                if (model.responsableSeleccionado != null && 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 => e.Dni_Denunciante == (Convert.ToInt32(model.dniDenunciante))).ToList();
                    //lista = lista.Where(e => String.Equals(e.Dni_Denunciante.Trim(),model.dniDenunciante.Trim())).ToList();
                    lista = lista.Where(e => !String.IsNullOrEmpty(e.Dni_Denunciante)).ToList();
                    lista = lista.Where(e => e.Dni_Denunciante.Trim().ToUpper().Contains(model.dniDenunciante.Trim().ToUpper())).ToList();
                }
                if (model.contestado)
                {
                    //lista = lista.Where(e => e.Contestado == model.contestado).ToList();
                    lista = lista.Where(e => e.Contestado == 1).ToList();
                }
                lista = lista.Where(e => e.Agendable).OrderBy(e => e.Fecha).ToList();
                if (lista.Count > 0)
                {
                    var listaNueva = from e in lista
                                     select new
                    {
                        e.Fecha,
                        e.DenunciaId,
                        e.Tipo_Evento,
                        e.Organismo,
                        e.Denunciante,
                        e.Dni_Denunciante,
                        e.Nro_Linea,
                        e.Servicio,
                        e.Provincia,
                        e.Nro_Expediente,
                        e.TramiteCRM,
                        e.Estado_Actual,
                        e.Requerimiento_Informe,
                        e.Solucionado,
                        e.Contestado_,
                        e.Responsable,
                        e.Estudio
                    };


                    var grid = new System.Web.UI.WebControls.GridView();
                    grid.DataSource = listaNueva;
                    grid.DataBind();

                    Response.ClearContent();
                    Response.AddHeader("content-disposition", "attachment; filename=Exported.xls");
                    Response.ContentType = "application/excel";
                    StringWriter   sw  = new StringWriter();
                    HtmlTextWriter htw = new HtmlTextWriter(sw);

                    grid.RenderControl(htw);

                    Response.Write(sw.ToString());

                    Response.End();
                }
                else
                {
                    RedirectToAction("ExcelVacio");
                }
            }
        }
예제 #3
0
        public ActionResult ExportarListAgenda([Bind(Include = "fechaDesde,fechaHasta,soloFechas,estudioSeleccionado,organismoSeleccionado,tipoEventoSeleccionado,reqInformeSeleccionado,solucionadoSeleccionado,provinciaSeleccionada,responsableSeleccionado,idDenuncia,dniDenunciante,contestado,CurrentPageIndex,PageCount,filtrarPorFechaVencimiento,filtrarPorFechaDenuncia,filtrarPorFechaNotificacion,filtrarPorFechaNotificacionGcia,esUnCambioMasivo")] AgendaModelView model)
        {
            List <AgendaExcelSP> lista = new List <AgendaExcelSP>();
            var fechaDesde             = model.fechaDesde;
            var fechaHasta             = model.fechaHasta;
            //var mes = (DateTime.Now.Month < 10) ? "0" + DateTime.Now.Month.ToString() : DateTime.Now.Month.ToString();
            //var dia = (DateTime.Now.Day < 10) ? "0" + DateTime.Now.Day.ToString() : DateTime.Now.Day.ToString();
            var fileName = "Agenda"
                           + DateTime.Now.Year.ToString()
                           + DateTime.Now.Month.ToString()
                           + DateTime.Now.Day.ToString()
                           + ".xlsx";

            using (var context = new NuevoDbContext())
            {
                if (model.filtrarPorFechaVencimiento)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaExcelDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToList();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaExcelHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                    else
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                }
                //else
                //if (model.filtrarPorFechaDenuncia && String.Equals(fechaDesde, fechaHasta))//cambiar fecha en Sp
                //{
                //    lista = context.Database
                //                .SqlQuery<AgendaExcelSP>("GetAgendaPorFechaDenunciaExcel @fecha", new SqlParameter("@fecha", fechaDesde))
                //                .ToList();
                //}
                //else
                //if (model.filtrarPorFechaDenuncia && !String.Equals(fechaDesde, fechaHasta))
                //{
                //    lista = context.Database
                //                .SqlQuery<AgendaExcelSP>("GetAgendaPorRangoFechaDenunciaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                //                .ToList();
                //}
                else
                if (model.filtrarPorFechaNotificacion)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionExcelDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToList();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionExcelHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                    else
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                }
                else
                if (model.filtrarPorFechaNotificacionGcia)
                {
                    if (String.IsNullOrEmpty(fechaHasta))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionGciaExcelDesde @fechaDesde", new SqlParameter("@fechaDesde", fechaDesde))
                                .ToList();
                    }
                    else
                    if (String.IsNullOrEmpty(fechaDesde))
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionGciaExcelHasta @fechaHasta", new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                    else
                    {
                        lista = context.Database
                                .SqlQuery <AgendaExcelSP>("GetAgendaPorFechasNotificacionGciaExcel @fechaDesde,@fechaHasta", new SqlParameter("@fechaDesde", fechaDesde), new SqlParameter("@fechaHasta", fechaHasta))
                                .ToList();
                    }
                }
                if (model.tipoEventoSeleccionado > 0)
                {
                    lista = lista.Where(e => e.TipoEventoId == model.tipoEventoSeleccionado).ToList();
                }
                if (model.organismoSeleccionado > 0)
                {
                    lista = lista.Where(e => e.ORGANISMO_ID == model.organismoSeleccionado).ToList();
                }
                if (model.reqInformeSeleccionado > 0)
                {
                    lista = lista.Where(e => e.REQUERIMIENTOINFORME == model.reqInformeSeleccionado).ToList();
                }
                if (model.solucionadoSeleccionado > 0)
                {
                    lista = lista.Where(e => e.SolucionadoId == model.solucionadoSeleccionado).ToList();
                }
                if (model.estudioSeleccionado > 0)
                {
                    lista = lista.Where(e => e.ESTUDIO_ID == model.estudioSeleccionado).ToList();
                }
                if (model.provinciaSeleccionada > 0)
                {
                    lista = lista.Where(e => e.Provincia_Id == 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 => e.Dni_Denunciante == (Convert.ToInt32(model.dniDenunciante))).ToList();
                    //lista = lista.Where(e => String.Equals(e.Dni_Denunciante.Trim(), model.dniDenunciante.Trim())).ToList();
                    lista = lista.Where(e => !String.IsNullOrEmpty(e.Dni_Denunciante)).ToList();
                    lista = lista.Where(e => e.Dni_Denunciante.Trim().ToUpper().Contains(model.dniDenunciante.Trim().ToUpper())).ToList();
                }
                if (model.contestado)
                {
                    //lista = lista.Where(e => e.Contestado == model.contestado).ToList();
                    lista = lista.Where(e => e.Contestado == 1).ToList();
                }

                lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.Fecha).ToList();
                if (lista.Count > 0)
                {
                    //lista = lista.Where(e => e.Agendable & (e.Deleted != true)).OrderBy(e => e.Fecha).ToList();
                    var listaNueva = from e in lista
                                     select new
                    {
                        //e.Fecha,
                        e.FechaEvento,
                        e.DenunciaId,
                        e.Tipo_Evento,
                        e.Organismo,
                        e.Denunciante,
                        e.Dni_Denunciante,
                        e.Nro_Linea,
                        e.Servicio,
                        e.Provincia,
                        e.Nro_Expediente,
                        e.TramiteCRM,
                        e.Estado_Actual,
                        e.Requerimiento_Informe,
                        e.Solucionado,
                        e.Contestado_,
                        e.Responsable,
                        e.Estudio,
                        e.Mediador,
                        e.Matricula,
                        e.Domicilio_Mediador
                        //,
                        //e.Fecha_Homologacion,
                        //e.Nro_Gestion_Coprec,
                        //e.Honorarios_Coprec,
                        //e.Fecha_Gestion_Honorarios,
                        //e.Monto_Acordado,
                        //e.Arancel,
                        //e.Fecha_Gestion_Arancel,
                        //e.Agenda_Coprec
                    };

                    var tabla = LinqQueryToDataTable(listaNueva);

                    var path = Server.MapPath("~/temp");
                    //var fileName = "Spreadsheet.xlsx";

                    if (Directory.Exists(path) == false)
                    {
                        Directory.CreateDirectory(path);
                    }
                    DataSet dataSet = new System.Data.DataSet("AgendaSpreadsheet");
                    dataSet.Tables.Add(tabla);
                    string fullPath = Path.Combine(path, fileName);
                    CreateExcelFile.CreateExcelDocument(dataSet, fullPath, includeAutoFilter: true);
                    return(Json(new { fileName = fileName, errorMessage = "" }));
                }
                else
                {
                    return(Json(new { fileName = "isEmpty", errorMessage = "" }));
                }
            }

            //return Json(new { fileName = fileName, errorMessage = "" });
        }
예제 #4
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));
        }
예제 #5
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));
        }