public async Task <RegixPersonModel> GetPersonFromRegixAsync(string identifier)
        {
            PersonSearchResultModel result = await _integrationService.GetPersonFromRegiXAsync(identifier);

            RegixPersonModel person = GetPersonViewModelFromResponse(result, identifier);

            return(person);
        }
Example #2
0
        public async Task <PersonSearchResultModel> GetPersonFromRegiXAsync(string identifier)
        {
            if (!_integrationSettings.UseRegiX)
            {
                throw new Exception("Integration with RegiX is not configured!");
            }

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

            RegiXReportModel report = await GetRegiXReportForPersonValidation();

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

            ServiceRequestData request = GetServiceRequestDataForPerson(report, identifier);

            if (request == null)
            {
                throw new Exception("Person 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 <ValidPersonResponse>(response);


            PersonSearchResultModel resultModel = new PersonSearchResultModel
            {
                PersonIdentifier = identifier,
                RequestId        = requestId,
                ResponseObject   = parsedObject
            };

            return(resultModel);
        }
        private RegixPersonModel GetPersonViewModelFromResponse(PersonSearchResultModel result, string searchIdentifier)
        {
            if (result == null || result.ResponseObject == null)
            {
                return(null);
            }

            ValidPersonResponse personResponse = result.ResponseObject as ValidPersonResponse;

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

            RegixPersonModel model = personResponse.ToViewModel();

            model.RequestId  = result.RequestId;
            model.Identifier = searchIdentifier;

            return(model);
        }