コード例 #1
0
ファイル: WalletService.cs プロジェクト: covi-id/cid-api-core
        public async Task <WalletStatusResponse> GetWalletStatus(string walletId, string key)
        {
            var wallet = await _walletRepository.GetAsync(Guid.Parse(walletId));

            if (wallet == null)
            {
                throw new NotFoundException(Messages.Wallet_NotFound);
            }

            var walletDetails = (await _walletDetailRepository.GetWalletDetailsByWallet(wallet)).FirstOrDefault();

            if (walletDetails == null)
            {
                throw new NotFoundException(Messages.WalltDetails_NotFound);
            }

            _cryptoService.DecryptAsUser(walletDetails, key);

            var photoUrl = _amazonS3Broker.GetImage(walletDetails.PhotoReference);

            var testResults = await _testResultService.GetTestResult(Guid.Parse(walletId));

            var response = new WalletStatusResponse
            {
                FirstName    = walletDetails.FirstName,
                LastName     = walletDetails.LastName,
                PhotoUrl     = photoUrl,
                ResultStatus = testResults == null?ResultStatus.Untested.ToString() : testResults.ResultStatus.ToString(),
                                   Status = testResults == null?Convert.ToInt32(ResultStatus.Untested) : (int)testResults?.ResultStatus
            };

            return(response);
        }