public IActionResult GetStudentQuestions(StudentQuestionAnswerFilterModel model) { try { var result = _StudentQuestionService.GetStudentQuestionAnswers(model); if (result.IsSucceeded) { return(Ok(result.Result)); } return(BadRequest(result.ErrorMessage)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ServiceResponse <List <StudentQuestionAnswer> > GetStudentQuestionAnswers(StudentQuestionAnswerFilterModel filter) { var response = new ServiceResponse <List <StudentQuestionAnswer> >(); response.IsSucceeded = true; response.RecordsTotal = StudentQuestionAnswerRepository.ListQueryable.Count(); response.RecordsFiltered = StudentQuestionAnswerRepository.ListQueryable.AddSearchFilters(filter).Count(); response.Result = StudentQuestionAnswerRepository.ListQueryable.AddSearchFilters(filter).AddOrderAndPageFilters(filter).ToList(); return(response); }
public static IQueryable <StudentQuestionAnswer> AddSearchFilters(this IQueryable <StudentQuestionAnswer> input, StudentQuestionAnswerFilterModel filter) { if (filter != null) { if (filter.Term?.Length > 0) { input = input.Where(x => x.StudentId.ToString().Contains(filter.Term)); } if (filter.Term?.Length > 0) { input = input.Where(x => x.QuestionId.ToString().Contains(filter.Term)); } } return(input); }