示例#1
0
        public ActionResult GenerateReport(DynamicReportRequest request, int districtId)
        {
            var user             = AppUserService.GetUser();
            var filterByDistrict = user.AppRole.Name != PortalRoleNames.DataOwner;
            var report           = DynamicReportingService.GetReportData(request, filterByDistrict ? districtId : (int?)null);
            var csvArray         = Csv.WriteCsvToMemory(report);
            var memoryStream     = new MemoryStream(csvArray);

            return(new FileStreamResult(memoryStream, "text/csv"));
        }
示例#2
0
        public ActionResult GetReportDefinitions(int schoolYearId)
        {
            var identity    = (ValidationPortalIdentity)User.Identity;
            var permissions = User.Identity.GetViewPermissions(identity.AppRole);

            var result = DynamicReportingService.GetReportDefinitions()
                         .Where(x => x.SchoolYearId == schoolYearId)
                         .Where(x => x.Enabled);

            if (!permissions.CanViewStudentLevelReports)
            {
                result = result.Where(x => x.IsOrgLevelReport);
            }

            var serializedResult = JsonConvert.SerializeObject(
                result.OrderBy(x => x.Name),
                Formatting.None,
                new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(Content(serializedResult, "application/json"));
        }