public JsonResult PopulateProduct(string searchTerm) { PopulateSecurityExtended(); //todo: re-factor it later as required var response = _sharedFunctions.PopulateProduct(false, SecurityExtended.LocationId.Value, searchTerm.Trim()); var productList = new List <Select2ViewModel>(); if (response != null && response.Any()) { foreach (var item in response) { var product = new Select2ViewModel(); product.id = item.ProductID; product.text = item.ProductDS; productList.Add(product); } } return(Json(productList, JsonRequestBehavior.AllowGet)); }
public JsonResult PopulateProducts(string searchTerm) { searchTerm = searchTerm.ToUpper(); var response = _sharedFunctions.PopulateProduct(false, 1, searchTerm.Trim().Replace("%", "[%]")); response = response.Where(r => r.ProductDS.ToUpper().Contains(searchTerm)).ToList(); var Products = new List <Select2ShortViewModel>(); if (response != null && response.Any()) { foreach (var item in response) { var Product = new Select2ShortViewModel(); Product.id = item.ProductID; Product.text = item.ProductDS; Products.Add(Product); } } return(Json(Products, JsonRequestBehavior.AllowGet)); }