Пример #1
0
        public StudentListOptionsModel GenerateListOptionsViewModel(EducationSecurityPrincipal user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var viewModel = new StudentListOptionsModel
            {
                IsProvider = !user.IsInRole(SecurityRoles.DataAdmin) && !user.IsInRole(SecurityRoles.SiteCoordinator) && user.IsInRole(SecurityRoles.Provider)
            };

            InitializeFilterLists(viewModel);
            return(viewModel);
        }
Пример #2
0
 public ProviderClientDataTable(HttpRequestBase request, EducationSecurityPrincipal currentUser)
     : base(request)
 {
     PartnerName     = ExtractFilterValue("PartnerName");
     IsAdministrator = currentUser.IsInRole(SecurityRoles.DataAdmin);
     ProviderIds     = currentUser.Identity.User.UserRoles.SelectMany(u => u.Providers).Select(p => p.Id);
 }
Пример #3
0
        public StudentClientDataTable(HttpRequestBase request, EducationSecurityPrincipal currentUser, IEnumerable <Property> studentProperties)
            : base(request)
        {
            InitializeRequestValues(request);
            IsAdministrator       = currentUser.IsInRole(SecurityRoles.DataAdmin);
            IsSiteCoordinator     = currentUser.IsInRole(SecurityRoles.SiteCoordinator);
            IsProvider            = currentUser.IsInRole(SecurityRoles.Provider);
            AssociatedSchoolIds   = currentUser.Identity.User.UserRoles.SelectMany(ur => ur.Schools).Select(s => s.Id).ToList();
            AssociatedProviderIds = currentUser.Identity.User.UserRoles.SelectMany(ur => ur.Providers).Select(p => p.Id).ToList();
            CurrentUserId         = currentUser.Identity.User.Id;
            int assignedServicePropertyId = GetPropertyId(studentProperties, () => (new Student()).StudentAssignedOfferings);
            int serviceRequestPropertyId  = GetPropertyId(studentProperties, () => (new Student()).ServiceRequests);

            IsAssignedServiceProtected = studentProperties.Where(p => p.Id == assignedServicePropertyId).Select(a => a.IsProtected).Distinct().Contains(true);
            IsServiceRequestProtected  = studentProperties.Where(p => p.Id == serviceRequestPropertyId).Select(p => p.IsProtected).Distinct().Contains(true);
            User = currentUser;
        }
 public ServiceOfferingClientDataTable(HttpRequestBase request, EducationSecurityPrincipal currentUser)
     : base(request)
 {
     ServiceTypeProviderOrProgramName = ExtractFilterValue("ServiceTypeProviderOrProgram");
     ServiceTypes              = ExtractFilterList("ServiceTypeFilters");
     ServiceCategories         = ExtractFilterList("ServiceCategoryFilters");
     CurrentUser               = currentUser.Identity.User;
     CanManageAll              = currentUser.IsInRole(SecurityRoles.DataAdmin) || currentUser.IsInRole(SecurityRoles.SiteCoordinator);
     UserAssociatedProviderIds = currentUser.Identity.User.UserRoles.SelectMany(u => u.Providers).Select(p => p.Id);
 }
 public void PopulateViewModel(EducationSecurityPrincipal user, ServiceTypeModel viewModel)
 {
     if (viewModel == null)
     {
         throw new ArgumentNullException("viewModel");
     }
     viewModel.IsAdministrator = user.IsInRole(SecurityRoles.DataAdmin);
     viewModel.Categories      = new MultiSelectList(CategoryRepository.Items, "Id", "Name", viewModel.SelectedCategories);
     viewModel.Programs        = new MultiSelectList(ProgramRepository.Items.Where(p => p.IsActive), "Id", "Name", viewModel.SelectedPrograms);
 }
        public IQueryable <Student> GetAllowedList(EducationSecurityPrincipal user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var associatedSchoolsIds = user.Identity.User.UserRoles.SelectMany(ur => ur.Schools).Select(s => s.Id);
            var isAdministrator      = user.IsInRole(SecurityRoles.DataAdmin);

            return(Items.Where(s => isAdministrator || !s.HasParentalOptOut || associatedSchoolsIds.Contains(s.SchoolId)));
        }
 public ServiceTypeListOptionsModel GenerateListOptionsViewModel(EducationSecurityPrincipal user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(new ServiceTypeListOptionsModel
     {
         AllowModifying = user.IsInRole(SecurityRoles.DataAdmin),
         CategoryFilterList = CategoryRepository.Items.Select(s => s.Name).ToList()
     });
 }
Пример #8
0
        public IEnumerable <int> GetFilteredFinderStudentIds(EducationSecurityPrincipal user, IClientDataTable <Student> dataTable)
        {
            IQueryable <Student> items = StudentRepository.Items;

            items = dataTable.ApplyFilters(items);
            items = dataTable.ApplySort(items);
            if (user.IsInRole(SecurityRoles.DataAdmin) || user.IsInRole(SecurityRoles.Provider))
            {
                return(items.Select(s => s.Id));
            }
            else
            {
                //if user has any associated schools (site coordinator)
                var userSchoolIds = user.Identity.User.UserRoles.SelectMany(ur => ur.Schools).Select(s => s.Id);
                if (userSchoolIds.Any())
                {
                    return(items.Where(s => userSchoolIds.Contains(s.School.Id)).Select(s => s.Id));
                }
                return(Enumerable.Empty <int>().ToList());
            }
        }
        public ServiceTypeModel GenerateEditViewModel(EducationSecurityPrincipal user, int typeId)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            var serviceType = ServiceTypeRepository.Items.Include(s => s.Categories).Include("ServiceOfferings.Program").SingleOrDefault(s => s.Id == typeId && s.IsActive);

            if (serviceType == null)
            {
                throw new EntityNotFoundException("Specified service type does not exist");
            }
            ServiceTypeModel viewModel = new ServiceTypeModel();

            viewModel.CopyFrom(serviceType);
            viewModel.Categories      = new MultiSelectList(CategoryRepository.Items, "Id", "Name", serviceType.Categories.Select(c => c.Id));
            viewModel.Programs        = new MultiSelectList(ProgramRepository.Items.Where(p => p.IsActive), "Id", "Name", serviceType.ServiceOfferings.Where(so => so.IsActive && so.Program.IsActive).Select(s => s.ProgramId).Distinct());
            viewModel.IsAdministrator = user.IsInRole(SecurityRoles.DataAdmin);
            return(viewModel);
        }
Пример #10
0
        public void Create(EulaModel viewModel, EducationSecurityPrincipal user)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (!user.IsInRole(SecurityRoles.DataAdmin))
            {
                throw new EntityAccessUnauthorizedException("user");
            }
            EulaAgreement agreement = new EulaAgreement
            {
                CreateTime   = DateTime.Now,
                CreatingUser = user.Identity.User
            };

            viewModel.CopyTo(agreement);
            EulaAgreementRepository.Add(agreement);
            EulaAcceptance acceptance = new EulaAcceptance
            {
                EulaAgreement  = agreement,
                CreatingUserId = user.Identity.User.Id,
                CreateTime     = DateTime.Now
            };

            if (user.Identity.User.EulaAcceptances == null)
            {
                user.Identity.User.EulaAcceptances = new List <EulaAcceptance>();
            }
            user.Identity.User.EulaAcceptances.Add(acceptance);
            UserRepository.Update(user.Identity.User);
            RepositoryContainer.Save();
        }
Пример #11
0
 public ServiceTypeClientDataTable(HttpRequestBase request, EducationSecurityPrincipal user)
     : base(request)
 {
     ServiceTypeName = ExtractFilterValue("ServiceTypeName");
     IsAdministrator = user.IsInRole(SecurityRoles.DataAdmin);
 }
 protected bool IsSiteCoordinator(EducationSecurityPrincipal user)
 {
     return user.IsInRole(SecurityRoles.SiteCoordinator);
 }
 protected bool IsProvider(EducationSecurityPrincipal user)
 {
     return user.IsInRole(SecurityRoles.Provider);
 }
 protected bool IsDataAdmin(EducationSecurityPrincipal user)
 {
     return user.IsInRole(SecurityRoles.DataAdmin);
 }
 protected bool IsDataAdmin(EducationSecurityPrincipal user)
 {
     return(user.IsInRole(SecurityRoles.DataAdmin));
 }
 protected bool IsProvider(EducationSecurityPrincipal user)
 {
     return(user.IsInRole(SecurityRoles.Provider));
 }
 protected bool IsSiteCoordinator(EducationSecurityPrincipal user)
 {
     return(user.IsInRole(SecurityRoles.SiteCoordinator));
 }