コード例 #1
0
        private IEnumerable <Student> GetStudents(int groupId, string searchString, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            var studentsQuery = new Query <Student>();

            studentsQuery.AddFilterClause(student => student.GroupId == groupId);
            if (searchString != null)
            {
                studentsQuery.AddFilterClause(student => student.LastName.Contains(searchString) ||
                                              student.FirstName.Contains(searchString));
            }

            IQueryable <Student> students = repositoriesContainer.StudentsRepository.GetAll(studentsQuery);

            return(students);
        }
コード例 #2
0
        public IEnumerable <Question> GetQuestionsForTest(int testId, string searchString = null)
        {
            IEnumerable <Question> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Question>();
                if (testId != 0)
                {
                    query.AddFilterClause(question => question.TestId == testId);
                }

                if (searchString != null)
                {
                    query.AddFilterClause(question => question.Title.Contains(searchString));
                }

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
コード例 #3
0
        public IList <Question> GetQuestionsByConceptId(int conceptId)
        {
            IList <Question> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Question>();
                query.AddFilterClause(question => question.ConceptId == conceptId);

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
コード例 #4
0
        public IEnumerable <Test> GetTestForLector(int currentUserId)
        {
            IEnumerable <Test> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Test>();
                query.AddFilterClause(test => test.Subject.SubjectLecturers.Any(sl => sl.LecturerId == currentUserId));

                searchResults = repositoriesContainer.TestsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
コード例 #5
0
        public IEnumerable <Question> GetQuestionsFromAnotherTests(int testId, int currentUserId)
        {
            IEnumerable <Question> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Question>();
                if (testId == 0)
                {
                    query.AddFilterClause(
                        question => question.Test.Subject.SubjectLecturers.Any(sl => sl.LecturerId == currentUserId));
                }
                else
                {
                    query.AddFilterClause(
                        question => question.TestId == testId);
                }

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
コード例 #6
0
        public IEnumerable <Test> GetTestsForSubject(int?subjectId)
        {
            IEnumerable <Test> searchResults;

            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query <Test>().Include(test => test.TestUnlocks);

                if (subjectId.HasValue)
                {
                    query.AddFilterClause(test => test.SubjectId == subjectId.Value);
                    query.Include(t => t.Questions);
                }

                searchResults = repositoriesContainer.TestsRepository.GetAll(query).ToList();
            }

            return(searchResults);
        }
コード例 #7
0
        public IEnumerable<Question> GetQuestionsForTest(int testId, string searchString = null)
        {
            IEnumerable<Question> searchResults;
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query<Question>();
                if (testId != 0)
                {
                    query.AddFilterClause(question => question.TestId == testId);
                }

                if (searchString != null)
                {
                    query.AddFilterClause(question => question.Title.Contains(searchString));
                }

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return searchResults;
        }
コード例 #8
0
        private IEnumerable<Student> GetStudents(int groupId, string searchString, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            var studentsQuery = new Query<Student>();
            studentsQuery.AddFilterClause(student => student.GroupId == groupId);
            if (searchString != null)
            {
                studentsQuery.AddFilterClause(student => student.LastName.Contains(searchString)
                    || student.FirstName.Contains(searchString));
            }

            IQueryable<Student> students = repositoriesContainer.StudentsRepository.GetAll(studentsQuery);
            
            return students;
        } 
コード例 #9
0
        public IEnumerable<Question> GetQuestionsFromAnotherTests(int testId, int currentUserId)
        {
            IEnumerable<Question> searchResults;
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query<Question>();
                if (testId == 0)
                {
                    query.AddFilterClause(
                        question => question.Test.Subject.SubjectLecturers.Any(sl => sl.LecturerId == currentUserId));
                }
                else
                {
                    query.AddFilterClause(
                        question => question.TestId == testId);
                }

                searchResults = repositoriesContainer.QuestionsRepository.GetAll(query).ToList();
            }

            return searchResults;
        }
コード例 #10
0
        public IEnumerable<Test> GetTestForLector(int currentUserId)
        {
            IEnumerable<Test> searchResults;
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query<Test>();
                query.AddFilterClause(test => test.Subject.SubjectLecturers.Any(sl => sl.LecturerId == currentUserId));

                searchResults = repositoriesContainer.TestsRepository.GetAll(query).ToList();
            }

            return searchResults;
        }
コード例 #11
0
        public IEnumerable<Test> GetTestsForSubject(int? subjectId)
        {
            IEnumerable<Test> searchResults;
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var query = new Query<Test>().Include(test => test.TestUnlocks);

                if (subjectId.HasValue)
                {
                    query.AddFilterClause(test => test.SubjectId == subjectId.Value);
                    query.Include(t => t.Questions);
                }

                searchResults = repositoriesContainer.TestsRepository.GetAll(query).ToList();
            }

            return searchResults;
        }