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 Categories table. Used to fill combo box. /// </summary> /// <returns>List of Categories</returns> public List <ModelNotifiedForCategories> GetAll_Categories(out string error) { error = null; CategoriesBsn bsn = new CategoriesBsn(wpfConfig); List <CategoriesInfo> dbItems = bsn.GetAll(); List <ModelNotifiedForCategories> notifiedItems = new List <ModelNotifiedForCategories>(); foreach (CategoriesInfo dbItem in dbItems) { ModelNotifiedForCategories itemToAdd = new ModelNotifiedForCategories(); Cloner.CopyAllTo(typeof(CategoriesInfo), dbItem, typeof(ModelNotifiedForCategories), itemToAdd); notifiedItems.Add(itemToAdd); } return(notifiedItems); }