private List <ModelNotifiedForEmployeeTerritories> FilterGrid(string filterValue) { filterValue = filterValue.ToLower(); List <ModelNotifiedForEmployeeTerritories> filteredList = new List <ModelNotifiedForEmployeeTerritories>(); foreach (ModelNotifiedForEmployeeTerritories item in EmployeeTerritoriesDataContext.modelNotifiedForEmployeeTerritoriesMain) { if (item.EmployeeID.ToString().ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } if (item.TerritoryID.ToString().ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } //Filter string values. if (item.TerritoryID != null) { if (item.TerritoryID.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } //Filter FK values. if (item.EmployeeID != null) { ModelNotifiedForEmployees comboItem = EmployeeTerritoriesDataContext.modelNotifiedForEmployees.Where(x => x.EmployeeID == item.EmployeeID).FirstOrDefault(); if ((comboItem != null) && (comboItem.LastName != null) && (comboItem.LastName.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } if (item.TerritoryID != null) { ModelNotifiedForTerritories comboItem = EmployeeTerritoriesDataContext.modelNotifiedForTerritories.Where(x => x.TerritoryID == item.TerritoryID).FirstOrDefault(); if ((comboItem != null) && (comboItem.TerritoryDescription != null) && (comboItem.TerritoryDescription.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } } return(filteredList); }
/// <summary> /// Retrieve all data from Employees table. Used to fill combo box. /// </summary> /// <returns>List of Employees</returns> public List <ModelNotifiedForEmployees> GetAll_Employees(out string error) { error = null; EmployeesBsn bsn = new EmployeesBsn(wpfConfig); List <EmployeesInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForEmployees> notifiedItems = new List <ModelNotifiedForEmployees>(); foreach (EmployeesInfo dbItem in dbItems) { ModelNotifiedForEmployees itemToAdd = new ModelNotifiedForEmployees(); Cloner.CopyAllTo(typeof(EmployeesInfo), dbItem, typeof(ModelNotifiedForEmployees), itemToAdd); notifiedItems.Add(itemToAdd); } return(notifiedItems); }