Exemplo n.º 1
0
        public PaginationDataList <StudentOut> SearchStudent(int?pageSize, int?pageRows, string name, int?classId,
                                                             int setStatus, int?setId, string mobile, DateTime?startTime, Guid userId)
        {
            name = Guard.EnsureParam(name);
            var admin = AdminRepository.FirstOrDefault(e => e.UserId == userId);

            if (admin == null)
            {
                return new PaginationDataList <StudentOut>()
                       {
                           CurrentPage = 0, ListData = new List <StudentOut>(), TotalPages = 0
                       }
            }
            ;
            var classList = ClassRepository.GetAllIncluding(x => x.Students).Where(e => e.InstitutionId == admin.InstitutionId);

            classList = FilterStudentByClassId(classId, classList);

            var studentList = classList.SelectMany(x => x.Students);

            studentList = studentList.Where(e => e.UserName.Contains(name) && e.Mobile.Contains(mobile));
            studentList = FilterStudentByStartTime(startTime, studentList);

            var studenAllocationList = studentList.SelectMany(e => e.StudentAllocations);

            IQueryable <StudentOut> studentOutList = FillData(studentList, studenAllocationList);

            studentOutList = FilterStudentBySetId(studentOutList, setId);
            studentOutList = FilterStudentBySetStatus(studentOutList, setStatus);

            return(studentOutList.ToPagination(pageSize, pageRows));
        }