private List <ModelNotifiedForProducts> FilterGrid(string filterValue) { filterValue = filterValue.ToLower(); List <ModelNotifiedForProducts> filteredList = new List <ModelNotifiedForProducts>(); foreach (ModelNotifiedForProducts item in ProductsDataContext.modelNotifiedForProductsMain) { if (item.ProductID.ToString().ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } //Filter string values. if (item.ProductName != null) { if (item.ProductName.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } if (item.QuantityPerUnit != null) { if (item.QuantityPerUnit.ToLower().Contains(filterValue)) { filteredList.Add(item); continue; } } //Filter FK values. if (item.SupplierID != null) { ModelNotifiedForSuppliers comboItem = ProductsDataContext.modelNotifiedForSuppliers.Where(x => x.SupplierID == item.SupplierID).FirstOrDefault(); if ((comboItem != null) && (comboItem.CompanyName != null) && (comboItem.CompanyName.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } if (item.CategoryID != null) { ModelNotifiedForCategories comboItem = ProductsDataContext.modelNotifiedForCategories.Where(x => x.CategoryID == item.CategoryID).FirstOrDefault(); if ((comboItem != null) && (comboItem.CategoryName != null) && (comboItem.CategoryName.ToLower().Contains(filterValue))) { filteredList.Add(item); continue; } } } return(filteredList); }
/// <summary> /// Retrieve all data from Suppliers table. Used to fill combo box. /// </summary> /// <returns>List of Suppliers</returns> public List <ModelNotifiedForSuppliers> GetAll_Suppliers(out string error) { error = null; SuppliersBsn bsn = new SuppliersBsn(wpfConfig); List <SuppliersInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForSuppliers> notifiedItems = new List <ModelNotifiedForSuppliers>(); foreach (SuppliersInfo dbItem in dbItems) { ModelNotifiedForSuppliers itemToAdd = new ModelNotifiedForSuppliers(); Cloner.CopyAllTo(typeof(SuppliersInfo), dbItem, typeof(ModelNotifiedForSuppliers), itemToAdd); notifiedItems.Add(itemToAdd); } return(notifiedItems); }