public List <SelectListItem> GetProductForSC(int?SC) { List <SelectListItem> SubCatogory = new List <SelectListItem>(); CommonService service = new CommonService(); List <Product> SubCatogoryList = new List <Product>(); SubCatogory.Add(new SelectListItem { Text = "Select", Value = "0" }); if ((SC != null) & (SC != 0)) { List <Product> SupplierList = service.AllProducts(); for (int i = 0; i < SupplierList.Count; i++) { if (SupplierList[i].SCId == SC) { SubCatogoryList.Add(SupplierList[i]); } } foreach (var item in SubCatogoryList) { var newItem = new SelectListItem { Text = item.ProName, Value = item.PROId.ToString() }; SubCatogory.Add(newItem); } } return(SubCatogory); }
public List <SelectListItem> AllProducts() { List <SelectListItem> Suppliers = new List <SelectListItem>(); CommonService service = new CommonService(); List <Product> SupplierList = service.AllProducts(); Suppliers.Add(new SelectListItem { Text = "Select", Value = "" }); foreach (var item in SupplierList) { var newItem = new SelectListItem { Text = item.ProName, Value = item.PROId.ToString() }; Suppliers.Add(newItem); } return(Suppliers); }