Ejemplo n.º 1
0
        public async Task <IActionResult> Index([Bind("FilterSurname,FilterName,FilterSecond_Name")] Models.EmployeeFilter.Filter filter)
        {
            var contextEmployees = await _context.Employees.ToListAsync();

            if (!string.IsNullOrWhiteSpace(filter.FilterSurname))
            {
                contextEmployees = contextEmployees
                                   .Where(s => s.Surname.Contains(filter.FilterSurname))
                                   .ToList();
            }
            if (!string.IsNullOrWhiteSpace(filter.FilterName))
            {
                contextEmployees = contextEmployees
                                   .Where(s => s.Name.Contains(filter.FilterName))
                                   .ToList();
            }
            if (!string.IsNullOrWhiteSpace(filter.FilterSecond_Name))
            {
                contextEmployees = contextEmployees
                                   .Where(s => s.Second_Name.Contains(filter.FilterSecond_Name))
                                   .ToList();
            }
            ViewData["Filter"] = filter;
            return(View(contextEmployees));
        }
Ejemplo n.º 2
0
 // GET: Employees
 public async Task <IActionResult> Index()
 {
     ViewData["Filter"] = new Models.EmployeeFilter.Filter();
     return(View(await _context.Employees.ToListAsync()));
 }