public async Task <PayeLevySubmissionsResponse> FindPayeSchemeLevySubmissions(string accountId, string hashedPayeRef)
        {
            var account = await _accountRepository.Get(accountId, AccountFieldsSelection.PayeSchemes);

            if (account == null)
            {
                return(new PayeLevySubmissionsResponse
                {
                    StatusCode = PayeLevySubmissionsResponseCodes.AccountNotFound
                });
            }

            var actualPayeId = _hashingService.DecodeValueToString(hashedPayeRef);

            var selectedPayeScheme = account.PayeSchemes.First(o => o.Ref.Equals(actualPayeId, StringComparison.OrdinalIgnoreCase));

            selectedPayeScheme.Ref = _payeSchemeObfuscator.ObscurePayeScheme(selectedPayeScheme.Ref);

            try
            {
                var levySubmissions = await _levySubmissionsRepository.Get(actualPayeId);

                return(new PayeLevySubmissionsResponse
                {
                    StatusCode = PayeLevySubmissionsResponseCodes.Success,
                    LevySubmissions = levySubmissions ?? new LevyDeclarations(),
                    PayeScheme = selectedPayeScheme
                });
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Unable to load Levy Declarations for Account Id {accountId} ");


                return(new PayeLevySubmissionsResponse
                {
                    StatusCode = PayeLevySubmissionsResponseCodes.UnexpectedError,
                    PayeScheme = selectedPayeScheme,
                });
            }
        }
Beispiel #2
0
 public string DecodeValueToString(string id)
 {
     return(_hashingServiceWithCorrectValuesForMarkerInterface.DecodeValueToString(id));
 }