public List <CustomerViewModel> SearchByKey(string id) { string[] Parameters = id.Split('|'); string param1 = Parameters[0]; string param2 = Parameters[1]; string param3 = Parameters[2]; var result = service.SearchByKey(param1, param2, param3); return(result); }
public ActionResult Index(string FullName, string CityCountry, string Email) { List <CustomerViewModel> list = null; var result = list; if (string.IsNullOrWhiteSpace(FullName) && string.IsNullOrWhiteSpace(CityCountry) && string.IsNullOrWhiteSpace(Email)) { // Get All Customer API Akses http://localhost:2099/api/CustomerApi/ without parameter string ApiEndPoint = ApiURL + "api/CustomerAPI/"; HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAsync(ApiEndPoint).Result; string ListResult = response.Content.ReadAsStringAsync().Result.ToString(); result = JsonConvert.DeserializeObject <List <CustomerViewModel> >(ListResult); } else if (!string.IsNullOrEmpty(FullName) || !string.IsNullOrEmpty(CityCountry) || !string.IsNullOrEmpty(Email)) { if (string.IsNullOrEmpty(FullName) || string.IsNullOrWhiteSpace(FullName)) { FullName = ""; } if (string.IsNullOrEmpty(CityCountry) || string.IsNullOrWhiteSpace(CityCountry)) { CityCountry = ""; } if (string.IsNullOrEmpty(Email) || string.IsNullOrWhiteSpace(Email)) { Email = ""; } result = service.SearchByKey(FullName, CityCountry, Email); // Get All Customer API Akses http://localhost:2099/api/CustomerApi/FullName/CityCountry/Email with parameter string ApiEndPoint = ApiURL + "api/CustomerAPI/SearchByKey/" + (FullName + "|" + CityCountry + "|" + Email); HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAsync(ApiEndPoint).Result; string ListResult = response.Content.ReadAsStringAsync().Result.ToString(); result = JsonConvert.DeserializeObject <List <CustomerViewModel> >(ListResult); } else { // Get All Customer API Akses http://localhost:2099/api/CustomerApi/ without parameter string ApiEndPoint = ApiURL + "api/CustomerAPI/"; HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAsync(ApiEndPoint).Result; string ListResult = response.Content.ReadAsStringAsync().Result.ToString(); result = JsonConvert.DeserializeObject <List <CustomerViewModel> >(ListResult); } return(View(result.ToList())); }