public ValueTask <PagedResult <AttendanceSheet> > RetrieveAttendanceSheets(
            SearchingOption searchingOption,
            OrderingOption orderingOption,
            PaginationOption paginationOption
            )
        {
            var attendanceSheets = RetrieveAll();

            attendanceSheets = Searching(attendanceSheets, searchingOption);
            attendanceSheets = Ordering(attendanceSheets, orderingOption);
            return(Pagination(attendanceSheets, paginationOption));
        }
示例#2
0
        public ValueTask <PagedResult <Lesson> > RetrieveLessons(
            SearchingOption searchingOption,
            OrderingOption orderingOption,
            PaginationOption paginationOption
            )
        {
            var lessons = RetrieveAll();

            lessons = Searching(lessons, searchingOption);
            lessons = Ordering(lessons, orderingOption);
            return(Pagination(lessons, paginationOption));
        }
示例#3
0
        public ValueTask <PagedResult <Student> > RetrieveStudents(
            SearchingOption searchingOption,
            OrderingOption orderingOption,
            PaginationOption paginationOption
            )
        {
            var students = RetrieveAll();

            students = Searching(students, searchingOption);
            students = Ordering(students, orderingOption);
            return(Pagination(students, paginationOption));
        }
示例#4
0
        public ValueTask <PagedResult <Lesson> > RetrieveEnrolledLessons(
            Guid studentId,
            SearchingOption searchingOption,
            OrderingOption orderingOption,
            PaginationOption paginationOption
            )
        {
            var enrolments = _context.Set <Enrolment>().AsQueryable();

            var enrolledLessons = enrolments
                                  .Include(enrolment => enrolment.Lesson)
                                  .Where(enrolment => enrolment.StudentId == studentId)
                                  .Select(enrolment => enrolment.Lesson);

            enrolledLessons = Searching(enrolledLessons, searchingOption);
            enrolledLessons = Ordering(enrolledLessons, orderingOption);
            return(Pagination(enrolledLessons, paginationOption));
        }
示例#5
0
 public async Task <IActionResult> GetLessons(
     [FromQuery] SearchingOption searchingOption,
     [FromQuery] OrderingOption orderingOption,
     [FromQuery] PaginationOption paginationOption
     )
 {
     try
     {
         var lessons = _uow.LessonRepository.RetrieveLessons(
             searchingOption,
             orderingOption,
             paginationOption
             );
         return(Ok(_mapper.Map <PagedLessonDTO>(await lessons)));
     }
     catch (Exception e)
     {
         _logger.LogError($"Error in action `GetLessons()`. {e.Message}");
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
示例#6
0
 public async Task <IActionResult> GetEnrolledStudents(
     [FromRoute] Guid lessonId,
     [FromQuery] SearchingOption searchingOption,
     [FromQuery] OrderingOption orderingOption,
     [FromQuery] PaginationOption paginationOption
     )
 {
     try
     {
         var enrolledStudents = _uow.StudentRepository.RetrieveEnrolledStudents(
             lessonId,
             searchingOption,
             orderingOption,
             paginationOption
             );
         return(Ok(_mapper.Map <PagedStudentDTO>(await enrolledStudents)));
     }
     catch (Exception e)
     {
         _logger.LogError($"Error in action `GetEnrolledStudents()`. {e.Message}");
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
        public IQueryable <AttendanceSheet> Searching(
            IQueryable <AttendanceSheet> source,
            SearchingOption searchingOption
            )
        {
            if (searchingOption == null)
            {
                searchingOption = new SearchingOption();
            }

            if (searchingOption.SearchOn == null || searchingOption.Search == null)
            {
                return(source);
            }

            var search = $"%{searchingOption.Search.ToLower()}%";

            switch (searchingOption.SearchOn.ToString())
            {
            case "title":
                return(source.Where(attendanceSheet => EF.Functions.Like(attendanceSheet.Lesson.Title, search)));
            }
            return(source);
        }
示例#8
0
        public IQueryable <Student> Searching(
            IQueryable <Student> source,
            SearchingOption searchingOption
            )
        {
            if (searchingOption == null)
            {
                searchingOption = new SearchingOption();
            }

            if (searchingOption.SearchOn == null || searchingOption.Search == null)
            {
                return(source);
            }

            var search = $"%{searchingOption.Search.ToLower()}%";

            switch (searchingOption.SearchOn.ToString())
            {
            case "firstname":
                return(source.Where(student => EF.Functions.Like(student.Firstname, search)));

            case "middlename":
                return(source.Where(student => EF.Functions.Like(student.Middlename, search)));

            case "lastname":
                return(source.Where(student => EF.Functions.Like(student.Lastname, search)));

            case "email":
                return(source.Where(student => EF.Functions.Like(student.Email, search)));

            case "phone":
                return(source.Where(student => EF.Functions.Like(student.Phone, search)));
            }
            return(source);
        }