public IEnumerable <StudentDto> Execute(StudentSearchQuery request) { var getStudents = _context.Students.AsQueryable(); if (request.Keyword != null) { getStudents = getStudents.Where(std => std.StudentName .ToLower() .Contains(request.Keyword.ToLower())); } if (request.OnlyActive.HasValue) { getStudents = getStudents.Where(std => std.IsDeleted != request.OnlyActive); } return(getStudents.Select(std => new StudentDto { Id = std.Id, StudentName = std.StudentName, StudyYear = std.StudyYear, NumberIndex = std.NumberIndex })); }
public ActionResult <IEnumerable <StudentDto> > Get([FromQuery] StudentSearchQuery query) { return(Ok(_getCommandStds.Execute(query))); //200 }
// GET: Students public ActionResult Index(StudentSearchQuery searchQuery) { var getStds = _getCommandStds.Execute(searchQuery); return(View(getStds)); }