/// <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); }
private List <ModelNotifiedForOrders> FilterGrid(string filterValue) { filterValue = filterValue.ToLower(); List <ModelNotifiedForOrders> filteredList = new List <ModelNotifiedForOrders>(); foreach (ModelNotifiedForOrders item in OrdersDataContext.modelNotifiedForOrdersMain) { if (item.OrderID.ToString().ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } //Filter string values. if (item.CustomerID != null) { if (item.CustomerID.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipName != null) { if (item.ShipName.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipAddress != null) { if (item.ShipAddress.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipCity != null) { if (item.ShipCity.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipRegion != null) { if (item.ShipRegion.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipPostalCode != null) { if (item.ShipPostalCode.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.ShipCountry != null) { if (item.ShipCountry.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } //Filter FK values. if (item.CustomerID != null) { ModelNotifiedForCustomers comboItem = OrdersDataContext.modelNotifiedForCustomers.Where(x => x.CustomerID == item.CustomerID).FirstOrDefault(); if ((comboItem != null) && (comboItem.ContactName != null) && (comboItem.ContactName.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } if (item.EmployeeID != null) { ModelNotifiedForEmployees comboItem = OrdersDataContext.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.ShipVia != null) { ModelNotifiedForShippers comboItem = OrdersDataContext.modelNotifiedForShippers.Where(x => x.ShipperID == item.ShipVia).FirstOrDefault(); if ((comboItem != null) && (comboItem.CompanyName != null) && (comboItem.CompanyName.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } } return(filteredList); }