public async Task <RegixCompanyModel> GetCompanyFromRegixAsync(string identifier)
        {
            CompanySearchResultModel result = await _integrationService.GetCompanyFromRegiXAsync(identifier);

            RegixCompanyModel company = GetCompanyViewModelFromResponse(result, identifier);

            company = await SetCompanyStatusInModel(company);

            return(company);
        }
예제 #2
0
        public async Task <CompanySearchResultModel> GetCompanyFromRegiXAsync(string identifier)
        {
            if (!_integrationSettings.UseRegiX)
            {
                throw new Exception("Integration with RegiX is not configured!");
            }

            if (String.IsNullOrWhiteSpace(identifier))
            {
                throw new Exception("Company identifier is missing");
            }

            RegiXReportModel report = await GetRegiXReportForCompanyValidation();

            if (report == null)
            {
                throw new Exception("RegiX report configuration not found for company validation");
            }

            ServiceRequestData request = GetServiceRequestDataForCompany(report, identifier);

            if (request == null)
            {
                throw new Exception("Company service request was not created");
            }

            // TODO: user, timestamp
            long requestId = await SaveRegiXRequest(request, report);

            // TODO: is context needed for transfering eAuth and certificate info?
            CustomCallContext context  = new CustomCallContext();
            RegiXResponse     response = await CallRegiXAsync(context, request);

            // TODO: errors
            await SaveRegiXResponse(requestId, response, "");

            BaseResponse parsedObject = XsdToObjectUtility.GetResponseObjectFromXsd <ValidUICResponse>(response);


            CompanySearchResultModel resultModel = new CompanySearchResultModel
            {
                CompanyIdentifier = identifier,
                RequestId         = requestId,
                ResponseObject    = parsedObject
            };

            return(resultModel);
        }
        private RegixCompanyModel GetCompanyViewModelFromResponse(CompanySearchResultModel result, string searchIdentifier)
        {
            if (result == null || result.ResponseObject == null)
            {
                return(null);
            }

            ValidUICResponse companyResponse = result.ResponseObject as ValidUICResponse;

            if (companyResponse == null)
            {
                throw new Exception("Could not convert response to ValidUICResponse");
            }

            RegixCompanyModel model = companyResponse.ToViewModel();

            model.RequestId = result.RequestId;
            model.Uic       = searchIdentifier;

            return(model);
        }