Exemple #1
0
        // GET: Employees
        public ActionResult Index(string query)
        {
            var employees = _employeeRepository.AllEmployees();

            if (!string.IsNullOrEmpty(query))
            {
                employees = employees
                            .Where(g =>
                                   g.LastName.Contains(query) ||
                                   g.Department.Name.Contains(query) ||
                                   g.Role.Name.Contains(query))
                ;
            }

            var viewModel = new EmployeeFormViewModel
            {
                Employees  = employees,
                SearchTerm = query
            };

            return(View("Index", viewModel));
        }