public async Task Transfer(TransferDTO transferDto) { var uri = "https://localhost:55163/api/Banking"; var response = _resilientHttpClient.Post(uri, transferDto); response.EnsureSuccessStatusCode(); }
public new void CleanUp() { transferDTO = null; AccountsBeforeChange = new Dictionary <string, BankAccount>(); AccountsAfterChange = new Dictionary <string, BankAccount>(); base.CleanUp(); }
public async Task <TransferListDTO> PerformTransfer(string phone, TransferDTO transferDTO) { var originCard = (await _cardRepository.FilterAsync(filter: c => c.Id == transferDTO.OriginCardId && c.Contact.Phone == phone, includeProperties: "Contact.Client,CardBatches.Batch,CardType")).FirstOrDefault(); if (originCard == null) { throw new InvalidOperationException(_resources.GetStringResource(LocalizationKeys.Application.exception_CardNotFound)); } var destinyContact = (await _contactRepository.FilterAsync(filter: (c) => c.Id == transferDTO.DestinyCard.ContactId, includeProperties: "Cards.CardBatches.Batch")).FirstOrDefault(); var destinyCard = destinyContact.Cards.FirstOrDefault((c) => c.CardTypeId == originCard.CardTypeId); if (destinyCard == null) { destinyCard = new Card(destinyContact, originCard.CardType.Currency, originCard.CardTypeId); } var transfer = new Transfer(originCard, destinyCard, new Money(transferDTO.Amount.Currency, transferDTO.Amount.Value), _resources.GetStringResource(LocalizationKeys.Application.messages_CreateTransferDisplayName)); destinyCard.DestinyTransfers.Add(transfer); _transferService.PerformTransfer(transfer); if (destinyCard.Id == 0) { _cardRepository.Add(destinyCard); } else { _cardRepository.Modify(destinyCard); } await _cardRepository.UnitOfWork.CommitAsync(); return(transfer.ProjectedAs <TransferListDTO>()); }
public void Test_Refund_GetRefundsForTransfer() { try { var wallet = this.GetNewJohnsWalletWithMoney(10000); TransferDTO transfer = this.GetNewTransfer(wallet); RefundDTO refund = this.GetNewRefundForTransfer(transfer); var pagination = new Pagination(1, 1); var filter = new FilterRefunds { ResultCode = transfer.ResultCode, Status = transfer.Status }; var sort = new Sort(); sort.AddField("CreationDate", SortDirection.desc); var refunds = Api.Refunds.GetRefundsForTransfer(transfer.Id, pagination, filter, sort); Assert.IsTrue(refunds.Count > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task <bool> InternalTransfer(TransferDTO internalTransferDTO) { try { var sender = await transferRepository.GetBankAccount(internalTransferDTO.SenderBranch, internalTransferDTO.SenderNumber, internalTransferDTO.SenderDigit); var receiver = await transferRepository.GetBankAccount(internalTransferDTO.ReceiverBranch, internalTransferDTO.ReceiverNumber, internalTransferDTO.ReceiverDigit); if (!SenderHasFunds(sender, internalTransferDTO.Value)) { return(UserDoesNotHaveFunds(sender)); } if (receiver == null) { return(ReceiverAccountNotFound()); } var result = await transferRepository.Transfer(internalTransferDTO); NotifyConsumers(internalTransferDTO); return(true); } catch (Exception ex) { NotifyErrorToConsumers(ex); return(false); } }
/// <summary>Creates refund object for transfer.</summary> /// <param name="transfer">Transfer.</param> /// <returns>Refund instance returned from API.</returns> protected async Task <RefundDTO> GetNewRefundForTransfer(TransferDTO transfer) { UserNaturalDTO user = await this.GetJohn(); RefundTransferPostDTO refund = new RefundTransferPostDTO(user.Id); return(await this.Api.Transfers.CreateRefund(transfer.Id, refund)); }
public async Task Transfer(TransferDTO transferDTO) { var uri = "http://microrabbit.banking.api/api/Banking"; var transferContent = new StringContent(JsonConvert.SerializeObject(transferDTO), Encoding.UTF8, "application/json"); var response = await this._apiClient.PostAsync(uri, transferContent); response.EnsureSuccessStatusCode(); }
public async Task Transfer(TransferDTO transferDTO) { var uri = "https://localhost:5001/api/Banking"; var transferContent = new StringContent(JsonConvert.SerializeObject(transferDTO), System.Text.Encoding.UTF8, "application/json"); var response = await _appClient.PostAsync(uri, transferContent); }
public async Task Transfer(TransferDTO transferDTO) { var url = "http://localhost:19917/api/Banking"; var transferContent = new StringContent(JsonConvert.SerializeObject(transferDTO), System.Text.Encoding.UTF8, "application/json"); var response = await _apiClient.PostAsync(url, transferContent); response.EnsureSuccessStatusCode(); }
public async Task Transfer(TransferDTO transferDTO) { var uri = @"https://localhost:5011/api/banking"; var content = new StringContent(JsonConvert.SerializeObject(transferDTO), Encoding.UTF8, "application/json"); var response = await _apiClient.PostAsync(uri, content); response.EnsureSuccessStatusCode(); }
/// <summary>Creates refund object for transfer.</summary> /// <param name="transfer">Transfer.</param> /// <returns>Refund instance returned from API.</returns> protected RefundDTO GetNewRefundForTransfer(TransferDTO transfer) { UserNaturalDTO user = this.GetJohn(); RefundTransferPostDTO refund = new RefundTransferPostDTO(user.Id); return(this.Api.Transfers.CreateRefund(transfer.Id, refund)); }
public async Task Transfer(TransferDTO transferDTO) { var uri = "https://localhost:5003/Transfer"; var transferContent = new StringContent(JsonConvert.SerializeObject(transferDTO), System.Text.Encoding.UTF8); var response = await _apiClient.PostAsync(uri, transferContent); response.EnsureSuccessStatusCode(); }
public async Task Transfer(TransferDTO dto) { var uri = "https://localhost:44393/api/Banking"; var transferContent = new StringContent(JsonConvert.SerializeObject(dto), System.Text.Encoding.UTF8, "application/json"); var reponse = await _httpClient.PostAsync(uri, transferContent); reponse.EnsureSuccessStatusCode(); }
public async Task <bool> Transfer(TransferDTO internalTransferDTO) { var receiver = await GetBankAccount(internalTransferDTO.ReceiverBranch, internalTransferDTO.ReceiverNumber, internalTransferDTO.ReceiverDigit); var sender = await GetBankAccount(internalTransferDTO.SenderBranch, internalTransferDTO.SenderNumber, internalTransferDTO.SenderDigit); receiver.UpdateBalance(internalTransferDTO.Value); sender.UpdateBalance(internalTransferDTO.Value * -1); return(true); }
public async Task <long> Save(TransferDTO entity) { try { return(await _transferDAL.Save(_mapper.Map <Transfer>(entity))); } catch (Exception ex) { return(0); } }
public void Test_Transfers_Get() { UserNaturalDTO john = this.GetJohn(); TransferDTO transfer = this.GetNewTransfer(); TransferDTO getTransfer = this.Api.Transfers.Get(transfer.Id); Assert.AreEqual(transfer.Id, getTransfer.Id); Assert.AreEqual(getTransfer.AuthorId, john.Id); Assert.AreEqual(getTransfer.CreditedUserId, john.Id); AssertEqualInputProps(transfer, getTransfer); }
public void Test_Transfers_Create() { UserNaturalDTO john = this.GetJohn(); TransferDTO transfer = this.GetNewTransfer(); WalletDTO creditedWallet = this.Api.Wallets.Get(transfer.CreditedWalletId); Assert.IsTrue(transfer.Id.Length > 0); Assert.AreEqual(transfer.AuthorId, john.Id); Assert.AreEqual(transfer.CreditedUserId, john.Id); Assert.IsTrue(creditedWallet.Balance.Amount == 100); }
public async Task <IActionResult> Transfer(TransferVM model) { var transferDto = new TransferDTO { FromAccount = model.FromAccount, ToAccount = model.ToAccount, TransferAmount = model.TransferAmount }; await _transferService.Transfer(transferDto); return(View("Index")); }
public async Task Transfer(TransferDTO transferDTO) { var uri = "https://localhost:5001/api/Banking";//TO DO: Move to appsettings var content = new StringContent( JsonConvert.SerializeObject(transferDTO), System.Text.Encoding.UTF8, "application/json" ); var response = await _apiClient.PostAsync(uri, content); response.EnsureSuccessStatusCode(); }
public async Task <IActionResult> Transfer(TransferViewModel model) { TransferDTO transferDTO = new TransferDTO() { FromAccount = model.FromAccout, ToAccount = model.ToAccount, TransferAmount = model.TransferAmount }; await _transferService.Transfer(transferDTO); return(View("Index")); }
public async Task <IActionResult> Transfer(TransferViewModel model) { TransferDTO transferDTO = new TransferDTO() { AmountToTransfer = model.Amount, SourceAccount = model.FromAccount, DestinationAccount = model.ToAccount }; await _transferService.transfer(transferDTO); return(View("Index")); }
public void Test_Refund_GetForTransfer() { TransferDTO transfer = this.GetNewTransfer(); RefundDTO refund = this.GetNewRefundForTransfer(transfer); UserNaturalDTO user = this.GetJohn(); RefundDTO getRefund = this.Api.Refunds.Get(refund.Id); Assert.AreEqual(getRefund.Id, refund.Id); Assert.AreEqual(getRefund.InitialTransactionId, transfer.Id); Assert.AreEqual(getRefund.AuthorId, user.Id); Assert.AreEqual(getRefund.Type, TransactionType.TRANSFER); }
public async Task <IActionResult> Transfer(TransferViewModel tvm) { TransferDTO transfer = new TransferDTO() { AccountFrom = tvm.FromAccount, AccountTo = tvm.ToAccount, TransferAmount = tvm.TransferAmount }; await _transferService.Transfer(transfer); return(View()); }
public void Test_Transfers_Create() { UserNaturalDTO john = TestHelper.GetJohn(); var wallet = TestHelper.GetNewJohnsWalletWithMoney(10000); TransferDTO transfer = TestHelper.GetNewTransfer(wallet); WalletDTO creditedWallet = TestHelper.WalletsApi.Get(transfer.CreditedWalletId).Result; Assert.True(transfer.Id.Length > 0); Assert.Equal(transfer.AuthorId, john.Id); Assert.Equal(transfer.CreditedUserId, john.Id); Assert.Equal(100, creditedWallet.Balance.Amount); }
public async Task <IActionResult> Post(TransferViewModel model) { var dto = new TransferDTO() { FromAccount = model.FromAccount, ToAccount = model.ToAccount, Amount = model.TransferAmount }; await _transferService.Transfer(dto); return(View("Index")); }
public async Task <IActionResult> Transfer(TransferViewModel model) { var dto = new TransferDTO { FromAccount = model.FromAccount, ToAccount = model.ToAccount, TransferAmount = model.TransferAmount }; await _transferService.Transfer(dto); return(View(nameof(Index))); }
public void Test_Idempotency_TransfersCreateRefunds() { string key = DateTime.Now.Ticks.ToString(); TransferDTO transfer = this.GetNewTransfer(); UserNaturalDTO user = this.GetJohn(); RefundTransferPostDTO refund = new RefundTransferPostDTO(user.Id); Api.Transfers.CreateRefund(key, transfer.Id, refund); var result = Api.Idempotency.Get(key); Assert.IsInstanceOf <RefundDTO>(result.Resource); }
public void Test_Transfers_Get() { UserNaturalDTO john = TestHelper.GetJohn(); var wallet = TestHelper.GetNewJohnsWalletWithMoney(10000); TransferDTO transfer = TestHelper.GetNewTransfer(wallet); TransferDTO getTransfer = _objectToTest.Get(transfer.Id).Result; Assert.Equal(transfer.Id, getTransfer.Id); Assert.Equal(getTransfer.AuthorId, john.Id); Assert.Equal(getTransfer.CreditedUserId, john.Id); TestHelper.AssertEqualInputProps(transfer, getTransfer); }
public async Task <IActionResult> Transfer(TransferViewModel model) { TransferDTO transferDto = new TransferDTO() { FromAccount = model.FromAccount, ToAccount = model.ToAccount, TransferAmount = model.TransferAmount }; await this._transferServiceProxy.Transfer(transferDto); return(Ok()); }
public void Test_Transfers_CreateRefund() { WalletDTO wallet = this.GetNewJohnsWalletWithMoney(10000); TransferDTO transfer = this.GetNewTransfer(wallet); WalletDTO walletBefore = this.Api.Wallets.Get(wallet.Id); RefundDTO refund = this.GetNewRefundForTransfer(transfer); WalletDTO walletAfter = this.Api.Wallets.Get(wallet.Id); Assert.IsTrue(refund.Id.Length > 0); Assert.IsTrue(refund.DebitedFunds.Amount == transfer.DebitedFunds.Amount); Assert.IsTrue(walletBefore.Balance.Amount == (walletAfter.Balance.Amount - transfer.DebitedFunds.Amount)); Assert.AreEqual(TransactionType.TRANSFER, refund.Type); Assert.AreEqual(TransactionNature.REFUND, refund.Nature); }