Exemple #1
0
        public void GetSubmittableSchoolYears_Should_ReturnAllEnabled()
        {
            var schoolYearService = new SchoolYearService(DbContextFactoryMock.Object);

            var result = schoolYearService.GetSubmittableSchoolYears();

            result.ShouldEqual(TestSchoolYears.Where(x => x.Enabled));
        }
Exemple #2
0
        public ActionResult Index()
        {
            var focusedSchoolYearId = AppUserService.GetSession().FocusedSchoolYearId;

            var focusedEdOrg = EdOrgService.GetEdOrgById(
                AppUserService.GetSession().FocusedEdOrgId,
                SchoolYearService.GetSchoolYearById(focusedSchoolYearId).Id);

            var recordsRequests = RecordsRequestService.GetAllRecordsRequests()
                                  .Where(x =>
                                         x.RespondingDistrict == focusedEdOrg.Id &&
                                         x.SchoolYearId == focusedSchoolYearId &&
                                         (x.Status == RecordsRequestStatus.PartialResponse || x.Status == RecordsRequestStatus.Requested)).ToList();

            foreach (var recordRequest in recordsRequests)
            {
                recordRequest.RequestingDistrictName = EdOrgService.GetEdOrgById(recordRequest.RequestingDistrict, focusedSchoolYearId).OrganizationName;
            }

            var model = new HomeIndexViewModel
            {
                AppUserSession             = AppUserService.GetSession(),
                Announcements              = AnnouncementService.GetAnnouncements(),
                YearsOpenForDataSubmission = SchoolYearService.GetSubmittableSchoolYears(),
                AuthorizedEdOrgs           = EdOrgService.GetAuthorizedEdOrgs(),
                FocusedEdOrg     = focusedEdOrg,
                RecordsRequests  = recordsRequests,
                SubmissionCycles = SubmissionCycleService.GetSubmissionCyclesOpenToday()
            };

            if (!model.AuthorizedEdOrgs.Any())
            {
                return(new HttpUnauthorizedResult("Unauthorized - no educational organizations assigned to user."));
            }

            return(View(model));
        }