Example #1
0
        private void SourceAndApplyPostcodeApiData(Org org, XElement element)
        {
            if (org == null)
            {
                throw new ArgumentNullException("org");
            }
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            var result = new XmlResult();

            if (!org.LaTried)
            {
                result = _thirdPartyApiManager.RequestLaApiResponse(element);

                org.LaData = result.Result.ToString();
            }
            else
            {
                result.ResultType = ResultTypeEnum.AlreadyTried;
            }

            if (result.ResultType != ResultTypeEnum.Success)
            {
                return;
            }

            _commandManager.UpdateOrgFromLaApiResponse(org, element);

            if (org.LaCode == null)
            {
                return;
            }

            var authority = _queryManager.GetAuthority(org.LaCode);

            if (authority == null)
            {
                return;
            }

            _commandManager.UpdateAuthority(org, authority.Id);
        }