public async Task Add_ShouldSucceed()
        {
            var addTransactionCommandFaker = new Common.Fakers.AddTransactionCommandFaker();
            var addTransactionCommand      = addTransactionCommandFaker.Generate();

            var mockTransactionRepository = new Mock <ITransactionRepository>();

            TransactionCommandHandler transactionCommandHandler = new TransactionCommandHandler(mockTransactionRepository.Object);
            await transactionCommandHandler.HandleAsync(addTransactionCommand);

            mockTransactionRepository.Verify(tr => tr.Add(It.Is <AddTransactionCommand>(ta => ta.IsDeepEqual(addTransactionCommand))));
            mockTransactionRepository.VerifyNoOtherCalls();
        }
        public IActionResult DeleteTransaction(int transactionId)
        {
            if (transactionId == null)
            {
                return(BadRequest());
            }

            try
            {
                var command = new DeleteTransactionCommand(transactionId);

                var commandHandler = new TransactionCommandHandler(_transactionRepository);

                commandHandler.Handle(command);

                return(Ok());
            }
            catch (CommandValidationException <eTransactionsError> ex)
            {
                return(BadRequest(ex.Error.ToString()));
            }
        }
        public IActionResult PutTransaction([FromBody] TransactionPutRequest transactionPutRequest, [FromRoute] int transactionId)
        {
            if (transactionPutRequest == null || transactionId == null)
            {
                return(BadRequest());
            }

            try
            {
                var command = transactionPutRequest.MapToCommand(transactionId);

                var commandHandler = new TransactionCommandHandler(_transactionRepository, _accountRepository);

                var transaction = commandHandler.Handle(command);

                var response = transaction.MapToResponse();

                return(Ok(response));
            }
            catch (CommandValidationException <eTransactionsError> ex)
            {
                return(BadRequest(ex.Error.ToString()));
            }
        }