Exemplo n.º 1
0
        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());
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        public void MapTest()
        {
            var people = new People()
            {
                Id = 1, Name = "a"
            };

            var mapped = ObjectPortMapper <People, Cat> .Map(people);
        }
Exemplo n.º 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());
        }
Exemplo n.º 5
0
        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());
        }