public IEnumerable <int> GetFilteredUserIds(IClientDataTable <User> dataTable)
        {
            IQueryable <User> items = UserRepository.Items;

            items = dataTable.ApplyFilters(items);
            items = dataTable.ApplySort(items);
            return(items.Select(u => u.Id));
        }
        public void GivenBinderCreatesResult_WhenGenerateDataTableResultViewModel_ThenReturnBindResult()
        {
            DataTableResultModel       expected     = new DataTableResultModel();
            DataTableRequestModel      requestModel = new DataTableRequestModel();
            IClientDataTable <Student> dataTable    = MockRepository.GenerateMock <IClientDataTable <Student> >();

            MockDataTableBinder.Expect(m => m.Bind(Repositories.MockStudentRepository.Items, dataTable, requestModel)).Return(expected);

            DataTableResultModel actual = Target.GenerateDataTableResultViewModel(requestModel, dataTable);

            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void GivenBinderCreatesResult_WhenGenerateDataTableResultViewModel_ThenReturnBindResult()
        {
            DataTableResultModel           expected     = new DataTableResultModel();
            DataTableRequestModel          requestModel = new DataTableRequestModel();
            IClientDataTable <CustomField> dataTable    = MockRepository.GenerateMock <IClientDataTable <CustomField> >();

            MockDataTableBinder.Expect(m => m.Bind(Arg <IQueryable <CustomField> > .List.ContainsAll(Repositories.MockCustomFieldRepository.Items.OfType <PrivateHealthField>()), Arg.Is(dataTable), Arg.Is(requestModel))).Return(expected);

            DataTableResultModel actual = Target.GenerateDataTableResultViewModel(requestModel, dataTable);

            Assert.AreEqual(expected, actual);
        }
        public void GivenBinderCreatesResult_WhenGenerateDataTableResultViewModel_ThenReturnBindResult()
        {
            DataTableResultModel        expected     = new DataTableResultModel();
            DataTableRequestModel       requestModel = new DataTableRequestModel();
            IClientDataTable <Provider> dataTable    = MockRepository.GenerateMock <IClientDataTable <Provider> >();
            var expectedQuery = Data.Providers.Where(p => p.IsActive);

            MockDataTableBinder.Expect(m => m.Bind(Arg <IQueryable <Provider> > .Matches(p => p.Where(pr => pr.IsActive).SequenceEqual(expectedQuery)), Arg.Is(dataTable), Arg.Is(requestModel))).Return(expected);

            DataTableResultModel actual = Target.GenerateDataTableResultViewModel(requestModel, dataTable);

            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
 public DataTableResultModel Bind <TEntity>(IQueryable <TEntity> items, IClientDataTable <TEntity> dataTable, DataTableRequestModel requestModel)
 {
     if (items == null)
     {
         throw new ArgumentNullException("items");
     }
     if (dataTable == null)
     {
         throw new ArgumentNullException("dataTable");
     }
     if (requestModel == null)
     {
         throw new ArgumentNullException("requestModel");
     }
     return(BindCore(items, dataTable, requestModel));
 }
        public override DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <CustomField> dataTable)
        {
            IQueryable <CustomField> items = CustomFieldRepository.Items.OfType <PublicField>();

            return(DataTableBinder.Bind <CustomField>(items, dataTable, requestModel));
        }
Exemple #7
0
 public abstract DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <CustomField> dataTable);
Exemple #8
0
        private static DataTableResultModel BindCore <TEntity>(IQueryable <TEntity> items, IClientDataTable <TEntity> dataTable, DataTableRequestModel requestModel)
        {
            IQueryable <TEntity> query = dataTable.ApplyFilters(items);

            query = dataTable.ApplySort(query);
            var resultSet = dataTable.CreateResultSet(query, requestModel);

            return(new DataTableResultModel
            {
                sEcho = requestModel.sEcho,
                iTotalRecords = items.Count(),
                iTotalDisplayRecords = query.Count(),
                aaData = resultSet
            });
        }
Exemple #9
0
        public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <Student> dataTable)
        {
            IQueryable <Student> items = StudentRepository.Items.Include(s => s.ApprovedProviders).
                                         Include(s => s.School).
                                         Include("CustomFieldValues.CustomDataOrigin.CreatingUser").
                                         Include("ServiceRequests.ServiceType").
                                         Include("ServiceRequests.Priority").
                                         Include("ServiceRequests.Subject").
                                         Include("ServiceRequests.FulfillmentDetails.FulfillmentStatus").
                                         Include("StudentAssignedOfferings.ServiceOffering.Provider").
                                         Include("StudentAssignedOfferings.ServiceOffering.ServiceType").
                                         Include("StudentAssignedOfferings.ServiceOffering.Program");

            return(DataTableBinder.Bind <Student>(items, dataTable, requestModel));
        }
 public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<ServiceOffering> dataTable)
 {
     IQueryable<ServiceOffering> items = ServiceOfferingRepository.Items.Where(s => s.IsActive);
     return DataTableBinder.Bind<ServiceOffering>(items, dataTable, requestModel);
 }
 public override DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<CustomField> dataTable)
 {
     IQueryable<CustomField> items = CustomFieldRepository.Items.OfType<PrivateHealthField>();
     return DataTableBinder.Bind<CustomField>(items, dataTable, requestModel);
 }
        public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <ServiceOffering> dataTable)
        {
            IQueryable <ServiceOffering> items = ServiceOfferingRepository.Items.Where(s => s.IsActive);

            return(DataTableBinder.Bind <ServiceOffering>(items, dataTable, requestModel));
        }
Exemple #13
0
        public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <ServiceAttendance> dataTable)
        {
            if (requestModel == null)
            {
                throw new ArgumentNullException("requestModel");
            }
            IQueryable <ServiceAttendance> items = ServiceAttendanceRepository.Items;

            return(DataTableBinder.Bind <ServiceAttendance>(items, dataTable, requestModel));
        }
Exemple #14
0
        public DataTableResultModel GenerateApprovalDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <Student> dataTable)
        {
            IQueryable <Student> items = StudentRepository.Items;

            return(DataTableBinder.Bind <Student>(items, dataTable, requestModel));
        }
Exemple #15
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 DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<User> dataTable)
 {
     IQueryable<User> items = UserRepository.Items.
                                                   Include("UserRoles.Role").
                                                   Include("UserRoles.Schools").
                                                   Include("UserRoles.Providers").
                                                   Include(u => u.LoginEvents);
     return DataTableBinder.Bind<User>(items, dataTable, requestModel);
 }
 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 DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<Student> dataTable)
 {
     IQueryable<Student> items = StudentRepository.Items.Include(s => s.ApprovedProviders).
                                                         Include(s => s.School).
                                                         Include("CustomFieldValues.CustomDataOrigin.CreatingUser").
                                                         Include("ServiceRequests.ServiceType").
                                                         Include("ServiceRequests.Priority").
                                                         Include("ServiceRequests.Subject").
                                                         Include("ServiceRequests.FulfillmentDetails.FulfillmentStatus").
                                                         Include("StudentAssignedOfferings.ServiceOffering.Provider").
                                                         Include("StudentAssignedOfferings.ServiceOffering.ServiceType").
                                                         Include("StudentAssignedOfferings.ServiceOffering.Program");
     return DataTableBinder.Bind<Student>(items, dataTable, requestModel);
 }
 public DataTableResultModel GenerateApprovalDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<Student> dataTable)
 {
     IQueryable<Student> items = StudentRepository.Items;
     return DataTableBinder.Bind<Student>(items, dataTable, requestModel);
 }
        public DataTableResultModel GenerateAuditLoginDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <LoginEvent> dataTable)
        {
            if (requestModel == null)
            {
                throw new ArgumentNullException("requestModel");
            }
            IQueryable <LoginEvent> items = LoginEventRepository.Items;

            return(DataTableBinder.Bind <LoginEvent>(items, dataTable, requestModel));
        }
        public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <User> dataTable)
        {
            IQueryable <User> items = UserRepository.Items.
                                      Include("UserRoles.Role").
                                      Include("UserRoles.Schools").
                                      Include("UserRoles.Providers").
                                      Include(u => u.LoginEvents);

            return(DataTableBinder.Bind <User>(items, dataTable, requestModel));
        }
 public DataTableResultModel GenerateAuditLoginDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<LoginEvent> dataTable)
 {
     if (requestModel == null)
     {
         throw new ArgumentNullException("requestModel");
     }
     IQueryable<LoginEvent> items = LoginEventRepository.Items;
     return DataTableBinder.Bind<LoginEvent>(items, dataTable, requestModel);
 }
 public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<ServiceAttendance> dataTable)
 {
     if (requestModel == null)
     {
         throw new ArgumentNullException("requestModel");
     }
     IQueryable<ServiceAttendance> items = ServiceAttendanceRepository.Items;
     return DataTableBinder.Bind<ServiceAttendance>(items, dataTable, requestModel);
 }
 public IEnumerable<int> GetFilteredUserIds(IClientDataTable<User> dataTable)
 {
     IQueryable<User> items = UserRepository.Items;
     items = dataTable.ApplyFilters(items);
     items = dataTable.ApplySort(items);
     return items.Select(u => u.Id);
 }
 public abstract DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<CustomField> dataTable);
 public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable<Program> dataTable)
 {
     IQueryable<Program> items = ProgramRepository.Items.Where(p => p.IsActive);
     return DataTableBinder.Bind<Program>(items, dataTable, requestModel);
 }
Exemple #27
0
        public DataTableResultModel GenerateDataTableResultViewModel(DataTableRequestModel requestModel, IClientDataTable <Program> dataTable)
        {
            IQueryable <Program> items = ProgramRepository.Items.Where(p => p.IsActive);

            return(DataTableBinder.Bind <Program>(items, dataTable, requestModel));
        }