public static UpdateAccountCommand MapToCommand(this AccountPutRequest account, int id)
        {
            if (account is null)
            {
                return(null);
            }

            return(new UpdateAccountCommand(id, account.Name, account.CPF, account.CurrentBalance, account.Historic));
        }
        public IActionResult PutAccount([FromBody] AccountPutRequest accountPutRequest, [FromRoute] int accountId)
        {
            if (accountPutRequest == null || accountId == null)
            {
                return(BadRequest());
            }

            try
            {
                var command = accountPutRequest.MapToCommand(accountId);

                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()));
            }
        }