示例#1
0
        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
            }));
        }
示例#2
0
 public ActionResult <IEnumerable <StudentDto> > Get([FromQuery] StudentSearchQuery query)
 {
     return(Ok(_getCommandStds.Execute(query))); //200
 }
示例#3
0
        // GET: Students
        public ActionResult Index(StudentSearchQuery searchQuery)
        {
            var getStds = _getCommandStds.Execute(searchQuery);

            return(View(getStds));
        }