Exemplo n.º 1
0
        public async Task <IActionResult> AddStudentsToLecturecise(StudentsFilterModel filters, string lectureciseId)
        {
            if (lectureciseId == null)
            {
                lectureciseId = filters.ParamId;
            }

            var lecturecise = await this.lectureciseService.GetById(lectureciseId);

            var students = await this.userService.GetAllStudentsByCourse(lecturecise.CourseId);

            var alreadyAddedStudents = await this.userService.GetAllStudentsByLecturecise(lecturecise.CourseId);

            students = students.Where(st => !alreadyAddedStudents.Any(aas => aas.Id == st.Id)).ToList();

            //Applying filters

            var filteredStudents = ApplyFilters(filters, students);

            filteredStudents = filteredStudents.OrderBy(s => s.StudentUniId).ToList();

            var addToCourseModel = new StudentsAddToCourseModel()
            {
                CourseId      = lecturecise.CourseId,
                LectureciseId = lecturecise.Id,
                StudentsInfo  = filteredStudents
            };

            return(View(addToCourseModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AllStudents(StudentsFilterModel filters = null)
        {
            var students = await this.userService.GetAllStudents();

            var filteredStudents = ApplyFilters(filters, students);

            filteredStudents = filteredStudents.OrderBy(s => s.StudentUniId).ToList();

            return(View(filteredStudents));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddStudentsToCourse(StudentsFilterModel filters = null)
        {
            var students = await this.userService.GetAllStudents();

            //Applying filters

            var filteredStudents = ApplyFilters(filters, students);

            filteredStudents = filteredStudents.OrderBy(s => s.StudentUniId).ToList();

            var addToCourseModel = new StudentsAddToCourseModel()
            {
                StudentsInfo = filteredStudents
            };

            return(View(addToCourseModel));
        }
Exemplo n.º 4
0
        private IList <StudentListViewModel> ApplyFilters(StudentsFilterModel filters, IList <StudentListViewModel> students)
        {
            if (students.Count > 0 && !string.IsNullOrWhiteSpace(filters.Major))
            {
                students = students.Where(st => (int)st.Major == int.Parse(filters.Major)).ToList();
            }

            if (students.Count > 0 && filters.GroupNumber > 0)
            {
                students = students.Where(st => st.GroupNumber == filters.GroupNumber).ToList();
            }

            if (students.Count > 0 && !string.IsNullOrWhiteSpace(filters.FacultyName))
            {
                students = students.Where(st => (int)st.FacultyName == int.Parse(filters.FacultyName)).ToList();
            }

            if (students.Count > 0 && filters.UniIdMin > 0)
            {
                students = students.Where(st => st.StudentUniId >= filters.UniIdMin).ToList();
            }

            if (students.Count > 0 && filters.UniIdMax < int.MaxValue)
            {
                students = students.Where(st => st.StudentUniId <= filters.UniIdMax).ToList();
            }

            if (students.Count > 0 && !string.IsNullOrWhiteSpace(filters.NameStr))
            {
                students = students.Where(st => st.UserInfo.FirstName.ToLower().Contains(filters.NameStr.ToLower()) ||
                                          st.UserInfo.FamilyName.ToLower().Contains(filters.NameStr.ToLower())).ToList();
            }

            if (students.Count > 0 && !string.IsNullOrWhiteSpace(filters.EmailStr))
            {
                students = students.Where(st => st.UserInfo.Email.ToLower().Contains(filters.EmailStr.ToLower()))
                           .ToList();
            }

            return(students);
        }