// GET: User public JsonResult ObtenerLista(DataTableAjaxPostModel ofilters, [Bind(Include = "interest_area_id,commission_id,status_id,origin_id,period_id")] ReportFilterViewModel Reportefiltros)//DataTableAjaxPostModel model { ConceptBL oConceptBL = new ConceptBL(); UserBL oUserBL = new UserBL(); //ConceptFiltersViewModel ofilters = new ConceptFiltersViewModel(); GridModel <ReportViewModel> grid = new GridModel <ReportViewModel>(); Reportefiltros.institution_ids = new List <int>(); if (AuthorizeUserAttribute.VerificarPerfil(AuthorizeUserAttribute.Permission.general_report_own_institution_support)) { Reportefiltros.institution_ids = oUserBL.ObtenerUser(AuthorizeUserAttribute.UsuarioLogeado().user_id).institution_ids; } if (AuthorizeUserAttribute.VerificarPerfil(AuthorizeUserAttribute.Permission.general_report_all_institution_support)) { Reportefiltros.institution_ids = null; } oConceptBL.ActualizarTablasReporte(Reportefiltros.period_id); grid = oConceptBL.ObtenerReporte(ofilters, Reportefiltros); grid.rows.ForEach(x => x.age = Helper.CalculateAge(x.birthdate.Value)); return(Json(new { // this is what datatables wants sending back draw = ofilters.draw, recordsTotal = grid.total, recordsFiltered = grid.recordsFiltered, data = grid.rows, })); }
public JsonResult ExportExcel([Bind(Include = "interest_area_id,commission_id,status_id,origin_id,period_id")] ReportFilterViewModel filtros) { UserBL oUserBL = new UserBL(); var fileName = "Reporte_" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".xlsx"; string errorMessage = ""; filtros.institution_ids = new List <int>(); if (AuthorizeUserAttribute.VerificarPerfil(AuthorizeUserAttribute.Permission.general_report_own_institution_support)) { filtros.institution_ids = oUserBL.ObtenerUser(AuthorizeUserAttribute.UsuarioLogeado().user_id).institution_ids; } if (AuthorizeUserAttribute.VerificarPerfil(AuthorizeUserAttribute.Permission.general_report_all_institution_support)) { filtros.institution_ids = null; } ConceptBL oConceptBL = new ConceptBL(); oConceptBL.ActualizarTablasReporte(filtros.period_id); List <ReportViewModel> resultado = oConceptBL.ObtenerExportarReporte(filtros); // resultado.ForEach(RecalcularCampos); string fullPath = Path.Combine(Server.MapPath("~/temp"), fileName); Stream fileBytes = CrearReporteExcel(resultado, fullPath, true); return(Json(new { fileName = fileName, errorMessage = errorMessage })); }