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)); }
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)); }
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)); }
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)); }
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)); } }
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); }
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); }