public static InsertAccountCommand MapToCommand(this AccountPostRequest account)
        {
            if (account is null)
            {
                return(null);
            }

            return(new InsertAccountCommand(0, account.Name, account.CPF, account.CurrentBalance, account.Historic));
        }
        public IActionResult PostAccount(AccountPostRequest accountPostRequest)
        {
            if (accountPostRequest == null)
            {
                return(BadRequest());
            }

            try
            {
                var command = accountPostRequest.MapToCommand();

                var commandHandler = new AccountCommandHandler(_accountRepository);

                var account = commandHandler.Handle(command);

                var response = account.MapToResponse();

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