public JsonResult SearchBisnodeForCVR(string cvr) { Bisnode.GreensWS_1SoapClient bisnodeClient = new Bisnode.GreensWS_1SoapClient(); var searchResult = bisnodeClient.FindCompany("bizdoc", "bizdoc4122", "company.ismaindepartment=true and company.statuscode=0 and Company.CVRNumber='" + cvr + "' Limit 8"); var results = searchResult.CompanyList; if (results != null && results.Count()>=1) { var company = results.First(); if (company.CVRNumber.Equals(cvr, StringComparison.InvariantCultureIgnoreCase)) { return new JsonResult() { Data = new { found = true, company = company }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } } return new JsonResult() { Data = new { found = false }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
public JsonResult SearchBisnode(string term) { if (term == null || term.Equals("")) { return null; } Bisnode.GreensWS_1SoapClient bisnodeClient = new Bisnode.GreensWS_1SoapClient(); var searchResult = bisnodeClient.FindCompany("bizdoc", "bizdoc4122", "company.ismaindepartment=true and company.statuscode=0 and company.name='" + term + "' Limit 100"); if (searchResult.CompanyList!=null) { var results = searchResult.CompanyList.Where(n => n.Name.StartsWith(term, StringComparison.OrdinalIgnoreCase)).Select(x => x.Name + " CVR: " + x.CVRNumber); if (results.Count() == 0) { results = searchResult.CompanyList.Select(x => x.Name + " CVR: " + x.CVRNumber); } return new JsonResult() { Data = results.ToArray(), JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } return null; }