public async Task <IActionResult> Index(string searchIndeks, string searchFirstName, string searchLastName)
        {
            IQueryable <Student> students = _context.Student.AsQueryable();

            if (!string.IsNullOrEmpty(searchIndeks))
            {
                students = students.Where(s => s.StudentId.Contains(searchIndeks));
            }
            if (!string.IsNullOrEmpty(searchFirstName))
            {
                students = students.Where(s => s.FirstName.Contains(searchFirstName));
            }
            if (!string.IsNullOrEmpty(searchLastName))
            {
                students = students.Where(s => s.LastName.Contains(searchLastName));
            }

            students = students.Include(s => s.Courses).ThenInclude(s => s.Course);

            var viewmodel = new StudentsFilter
            {
                Students = await students.ToListAsync()
            };

            return(View(viewmodel));
        }
示例#2
0
        public List <Student> GetStudentResultSet(string name, string gender)
        {
            StudentsFilter inputparams = new StudentsFilter()
            {
                Name   = name,
                Gender = gender
            };

            List <Student> studentlist = db.StudentFilterResultSet.CallStoredProc(inputparams).ToList <Student>();

            return(studentlist);
        }