Exemple #1
0
        public async ValueTask <ActionResult <List <long> > > CreateTransferTransaction([FromBody] TransferInputModel transactionModel)
        {
            if (await _repo.GetById(transactionModel.AccountId) is null)
            {
                return(BadRequest("The account is not found"));
            }
            if (transactionModel.CurrencyId <= 0)
            {
                return(BadRequest("The currency is missing"));
            }
            string badRequest = await FormBadRequest(transactionModel.Amount, transactionModel.AccountId);

            if (!string.IsNullOrWhiteSpace(badRequest))
            {
                return(Problem("Not enough money on the account", statusCode: 418));
            }
            var transfer    = _mapper.Map <TransferTransactionDto>(transactionModel);
            var dataWrapper = await _repo.AddTransfer(transfer);

            _logger.Info($"Create Transfer Transaction with Amount = {transfer.Amount} {transfer.Currency} from AccountId [{transfer.AccountId}] for AccountId [{transfer.AccountIdReceiver}]");
            return(MakeResponse(dataWrapper));
        }