public async Task <IActionResult> TransferAsync(StartTransferInput dto)
        {
            var source = dto.SourceAccount;

            if (!await _accountQueryService.HasAccountAsync(source.Id))
            {
                return(NotFound("The source account does not exist."));
            }

            var sink = dto.SinkAccount;

            if (!await _accountQueryService.HasAccountAsync(sink.Id))
            {
                return(NotFound("The sink account does not exist."));
            }

            var command = new StartTransferApplicationCommand()
            {
                Amount        = dto.Amount,
                SourceAccount = ObjectPortMapper <StartTransferInput.TransferAccount, StartTransferApplicationCommand.TransferAccount> .Map(source),
                SinkAccount   = ObjectPortMapper <StartTransferInput.TransferAccount, StartTransferApplicationCommand.TransferAccount> .Map(sink)
            };

            await _eBankApplicationService.TransferFundsAsync(command);

            return(Accepted());
        }
Beispiel #2
0
        public async Task <IActionResult> OpenAsync([FromBody] OpenBankAccountInput dto)
        {
            var command = ObjectPortMapper <OpenBankAccountInput, OpenBankAccountApplicationCommand> .Map(dto);

            var result = await _eBankApplicationService.OpenAccountAsync(command);

            return(ExecutionResult(result));
        }
Beispiel #3
0
        public void MapTest()
        {
            var people = new People()
            {
                Id = 1, Name = "a"
            };

            var mapped = ObjectPortMapper <People, Cat> .Map(people);
        }
Beispiel #4
0
        public async Task <IActionResult> ChangeNameAsync(ChangeAccountNameInput dto)
        {
            if (!await _accountQueryService.HasAccountAsync(dto.AccountId))
            {
                return(NotFound("The bank account does not exist."));
            }

            var command = ObjectPortMapper <ChangeAccountNameInput, ChangeAccountNameApplicationCommand> .Map(dto);

            await _eBankApplicationService.ChangeAccountNameAsync(command);

            return(Accepted());
        }
        public async Task <IActionResult> WithdrawAsync(StartWithdrawInput dto)
        {
            if (!await _accountQueryService.HasAccountAsync(dto.AccountId))
            {
                return(NotFound("The bank account does not exist."));
            }

            var command = ObjectPortMapper <StartWithdrawInput, StartWithdrawApplicationCommand> .Map(dto);

            await _eBankApplicationService.WithdrawFundsAsync(command);

            return(Accepted());
        }