public static IEnumerable<AssociatedSchool> GetAssociatedSchoolsWithClaim(UserInformation userInfo, string claimType, EntryRequest request)
        {
            if (!request.LocalEducationAgencyId.HasValue)
            {
                return
                    (from school in userInfo.AssociatedSchools
                     where school.ClaimTypes.Any(ct => ct == claimType)
                     select new AssociatedSchool
                     {
                         LocalEducationAgencyId = school.LocalEducationAgencyId,
                         SchoolId = school.SchoolId,
                         SchoolName = school.Name
                     });
            }

            return
                (from school in userInfo.AssociatedSchools
                 where school.ClaimTypes.Any(ct => ct == claimType) && school.LocalEducationAgencyId == request.LocalEducationAgencyId
                 select new AssociatedSchool
                 {
                     LocalEducationAgencyId = school.LocalEducationAgencyId,
                     SchoolId = school.SchoolId,
                     SchoolName = school.Name
                 });
        }
        public static bool HasStudents(IRepository<StaffStudentAssociation> staffStudentAssociationRepository, AssociatedSchool associatedSchool, UserInformation userInformation)
        {
            var staffStudenAssociation = (from ssa in staffStudentAssociationRepository.GetAll()
                                          where ssa.StaffUSI == userInformation.StaffUSI &&
                                                ssa.SchoolId == associatedSchool.SchoolId
                                          select ssa).FirstOrDefault();

            return staffStudenAssociation != null;
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            session = IoC.Resolve<ISessionStateProvider>();

            this.UserInformation = UserInformation.Current;

            // Only generate this in Test environments...
            if (ShowExceptionDetails)
                RegisterFullExceptionScripts(); 

            SetErrorMessage();
        }
        public static int? GetAssociatedLocalEducationAgencyWithClaim(UserInformation userInfo, string claimType, EntryRequest request)
        {
            if (!request.LocalEducationAgencyId.HasValue)
            {
                return (from lea in userInfo.AssociatedLocalEducationAgencies
                        where lea.ClaimTypes.Any(ct => ct == claimType)
                        select (int?)lea.LocalEducationAgencyId)
                    .FirstOrDefault();
            }

            return (from lea in userInfo.AssociatedLocalEducationAgencies
                    where lea.ClaimTypes.Any(ct => ct == claimType)
                          && lea.LocalEducationAgencyId == request.LocalEducationAgencyId
                    select (int?)lea.LocalEducationAgencyId)
                .FirstOrDefault();
        }
Beispiel #5
0
 protected void LoginUser(UserInformation userInformation)
 {
     // Create and attach a claims based principal to the current thread
     Thread.CurrentPrincipal = userInformation.ToClaimsPrincipal();
 }
Beispiel #6
0
        protected override void EstablishContext()
        {
            providedStaffUSI = providedStaffUSI1;
            providedUserName = "******";
            providedUserInformation = new UserInformation
            {
                StaffUSI = providedStaffUSI,
                FullName = providedFullName,
                AssociatedOrganizations = new List<UserInformation.EducationOrganization>
                                                                            {
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId)
                                                                                { 
                                                                                    Name = providedSchoolName, 
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 1)
                                                                                { 
                                                                                    Name = providedSchoolName1,
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 2)
                                                                                { 
                                                                                    Name = providedSchoolName2,
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 3)
                                                                                { 
                                                                                    Name = providedSchoolName3,
                                                                                },
                                                                            }
            };

            suppliedViewType = StaffModel.ViewType.SubjectSpecificOverview.ToString();

            staffCohortRepository = mocks.StrictMock<IRepository<StaffCohort>>();
            Expect.Call(staffCohortRepository.GetAll()).Return(GetStaffCohort());
            
            staffInfoRepository = mocks.StrictMock<IRepository<StaffInformation>>();
            Expect.Call(staffInfoRepository.GetAll()).Return(GetStaffInformation());

            teacherSectionRepository = mocks.StrictMock<IRepository<TeacherSection>>();
            Expect.Call(teacherSectionRepository.GetAll()).Repeat.Any().Return(GetTeacherSection());

            schoolInformationRepository = mocks.StrictMock<IRepository<SchoolInformation>>();
            Expect.Call(schoolInformationRepository.GetAll()).Repeat.Any().Return(GetSchoolInformation());

            WatchListRepository = mocks.StrictMock<IRepository<MetricBasedWatchList>>();
            Expect.Call(WatchListRepository.GetAll()).Repeat.Any().Return(GetWatchListInformation());

            WatchListOptionRepository = mocks.StrictMock<IRepository<MetricBasedWatchListOption>>();
            Expect.Call(WatchListOptionRepository.GetAll()).Repeat.Any().Return(GetWatchListOptionInformation());

            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(String.Empty, 0)).
                IgnoreArguments().Repeat.Any().Return(true);

            LoginUser(providedUserInformation);

            base.EstablishContext();
        }
Beispiel #7
0
 protected override void EstablishContext()
 {
     providedStaffUSI = providedStaffUSI1;
     providedUserName = "******";
     providedUserInformation = new UserInformation
                                   {
                                       StaffUSI = providedStaffUSI,
                                       FullName = providedFullName,
                                       AssociatedOrganizations = new List<UserInformation.EducationOrganization>
                                                                     {
                                                                         new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId)
                                                                         { 
                                                                             Name = providedSchoolName,
                                                                         },
                                                                         new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 1)
                                                                         { 
                                                                             Name = providedSchoolName1,
                                                                         },
                                                                         new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 2)
                                                                         { 
                                                                             Name = providedSchoolName2,
                                                                         },
                                                                         new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 3)
                                                                         { 
                                                                             Name = providedSchoolName3,
                                                                         },
                                                                     }
                                   };
     base.EstablishContext();
 }
Beispiel #8
0
 protected void LoginUser(UserInformation userInformation)
 {
     Thread.CurrentPrincipal = userInformation.ToClaimsPrincipal();
 }
Beispiel #9
0
 protected override void EstablishContext()
 {
     providedStaffUSI = providedStaffUSI1+100;
     providedUserName = "******";
     var claimTypes = new List<String>
                          {
                              EdFiClaimTypes.ViewAllStudents
                          };
     providedUserInformation = new UserInformation
                                   {
                                       StaffUSI = providedStaffUSI,
                                       FullName = providedFullName,
                                       AssociatedOrganizations = new List<UserInformation.EducationOrganization>
                                                                     {
                                                                         new UserInformation.LocalEducationAgency
                                                                             (providedSchoolId + 16)
                                                                             {
                                                                                 Name = "My ISD",
                                                                                 ClaimTypes = claimTypes
                                                                             }
                                                                     }
                                   };
     base.EstablishContext();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     session = IoC.Resolve<ISessionStateProvider>();
     this.UserInformation = UserInformation.Current;
 }
Beispiel #11
0
 protected void LoginUser(string userName, string[] roleNames, UserInformation userInformation)
 {
     // Create and attach a claims based principal to the current thread
     Thread.CurrentPrincipal = userInformation.ToClaimsPrincipal(userName, roleNames);
 }
        public HashSet<long> GetAllStudentsForAllUserOrganizations(UserInformation userInfo)
        {
            var result = new HashSet<long>();

            var userOrgs = userInfo.AssociatedOrganizations;
            foreach (var userOrg in userOrgs)
            {
                var schoolStudents = GetStudentUSIsForSchool(userOrg.EducationOrganizationId);
                result.UnionWith(schoolStudents);
            }

            return result;
        }
Beispiel #13
0
        protected override void EstablishContext()
        {
            base.EstablishContext();

            staffStudentAssociationRepository = mocks.StrictMock<IRepository<StaffStudentAssociation>>();
            rootMetricNodeResolver = mocks.StrictMock<IRootMetricNodeResolver>();
            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            windsorContainer = new WindsorContainer();
            RegisterProviders(windsorContainer);

            userEntryProvider = windsorContainer.Resolve<IUserEntryProvider>();

            var suppliedUserInformation = new UserInformation
                                                {
                                                    StaffUSI = suppliedStaffUSI,
                                                    AssociatedOrganizations = new List<UserInformation.EducationOrganization>()
                                                                                {
                                                                                    new UserInformation.School(suppliedLocalEducationAgencyId, suppliedSchoolId)
                                                                                        {
                                                                                            ClaimTypes = new List<string>
                                                                                                                {
                                                                                                                    EdFiClaimTypes.ViewAllTeachers
                                                                                                                }
                                                                                        }
                                                                                }
                                                };
            Thread.CurrentPrincipal = suppliedUserInformation.ToClaimsPrincipal();
        }
Beispiel #14
0
        protected override void EstablishContext()
        {
            suppliedUserInformation = new UserInformation
            {
                StaffUSI = suppliedStaffUSI,
                FullName = suppliedStaffFullName,
                AssociatedOrganizations = new List<UserInformation.EducationOrganization>
                                                        {
                                                            new UserInformation.School(suppliedLocalEducationAgencyId, suppliedSchoolId)
                                                                {
                                                                    Name = suppliedSchoolName,
                                                                    ClaimTypes = new List<string>{EdFiClaimTypes.ViewMyStudents, EdFiClaimTypes.ViewAllMetrics}
                                                                },
                                                            new UserInformation.School(suppliedLocalEducationAgencyId, suppliedSchoolId2)
                                                                {
                                                                    Name = suppliedSchoolName2,
                                                                    ClaimTypes = new List<string>{EdFiClaimTypes.ViewMyStudents, EdFiClaimTypes.ViewAllMetrics}
                                                                },
                                                        }
            };
            expectedUrl = staffAreaLinksFake.Default(suppliedSchoolId2, suppliedStaffUSI, suppliedStaffFullName);

            base.EstablishContext();
        }