public ServiceResponse <List <Answer> > GetAnswers(AnswerFilterModel filter) { var response = new ServiceResponse <List <Answer> >(); response.IsSucceeded = true; response.RecordsTotal = AnswerRepository.ListQueryable.Count(); response.RecordsFiltered = AnswerRepository.ListQueryable.AddSearchFilters(filter).Count(); response.Result = AnswerRepository.ListQueryable.AddSearchFilters(filter).AddOrderAndPageFilters(filter).ToList(); return(response); }
public ActionResult IndexAjax(AnswerFilterModel filter) { var answerQuery = AnswerRepository.All; if (!string.IsNullOrWhiteSpace(filter.AnswerText)) { answerQuery = answerQuery.Where(p => p.AnswerText.Contains(filter.AnswerText)); } var model = answerQuery.ToList(); return(PartialView("_IndexTable", model)); }
public IActionResult GetAnswers(AnswerFilterModel model) { try { var result = _AnswerService.GetAnswers(model); if (result.IsSucceeded) { return(Ok(result.Result)); } return(BadRequest(result.ErrorMessage)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult IndexAjax(AnswerFilterModel filter) { var answerQuery = AnswerRepository.All; if (!string.IsNullOrWhiteSpace(filter.AnswerText)) answerQuery = answerQuery.Where(p => p.AnswerText.Contains(filter.AnswerText)); var model = answerQuery.ToList(); return PartialView("_IndexTable", model); }
public static IQueryable <Answer> AddSearchFilters(this IQueryable <Answer> input, AnswerFilterModel filter) { if (filter != null) { if (filter.Term?.Length > 0) { input = input.Where(x => x.Responce.Contains(filter.Term)); } } return(input); }