public JsonResult PopulateWasteClass(string searchTerm) { searchTerm = searchTerm.ToUpper(); //todo: re-factor it later as required var response = _sharedFunctions.PopulateWasteClassTypes(false); response = response.Where(r => r.WasteClassTypeDS.ToUpper().Contains(searchTerm)).ToList(); var WasteClassList = new List <Select2ViewModel>(); if (response != null && response.Any()) { foreach (var item in response) { var WasteClass = new Select2ViewModel(); WasteClass.id = item.WasteClassTypeCd; WasteClass.text = item.WasteClassTypeDS; WasteClassList.Add(WasteClass); } } return(Json(WasteClassList, JsonRequestBehavior.AllowGet)); }