public async Task ShouldSearchForCompaniesUsingCompanyHouseService()
        {
            //Arrange
            var searchTerm = "test";
            var results    = new CompanySearchResults();

            _verificationService.Setup(x => x.FindCompany(It.IsAny <string>(), 10)).ReturnsAsync(results);

            //Act
            await _searchService.Search(searchTerm, 10);

            //Assert
            _verificationService.Verify(x => x.FindCompany(searchTerm, 10), Times.Once);
        }
Example #2
0
        public IActionResult Search([FromBody] CompanySearchRequest body)
        {
            try
            {
                if (body == null)
                {
                    return(BadRequest());
                }

                CompanySearchResults result = _companyService.Search(body);
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.ToString()));
            }
        }
Example #3
0
    protected DataSet CompanyGrid_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords)
    {
        try
        {
            IDataComConfiguration configuration = DataComHelper.GetConfiguration(SiteIdentifierParameter);
            DataComClient         client        = DataComHelper.CreateClient(configuration);
            ICompanyProvider      provider      = DataComHelper.CreateCompanyProvider(client, configuration);
            CompanySearchResults  response      = provider.SearchCompanies(CurrentCompanyFilter, currentOffset / currentPageSize, currentPageSize);
            DataTable             table         = new DataTable("Companies");
            table.Columns.Add("CompanyId", typeof(long));
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Country", typeof(string));
            table.Columns.Add("City", typeof(string));
            foreach (CompanySearchResult result in response.Results)
            {
                DataRow row = table.NewRow();
                row["CompanyId"] = result.CompanyId;
                row["Name"]      = result.Name;
                row["Country"]   = result.Country;
                row["City"]      = result.City;
                table.Rows.Add(row);
            }
            DataSet dataSet = new DataSet();
            dataSet.Tables.Add(table);
            int maxHitCount = currentPageSize * MAX_PAGE_COUNT;
            int hitCount    = (int)response.TotalHits;
            if (hitCount > maxHitCount)
            {
                hitCount = maxHitCount;
                ShowWarning(GetString("datacom.toomanycompanies"), null, null);
            }
            totalRecords = hitCount;
            return(dataSet);
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
        totalRecords = 0;

        return(null);
    }