Exemplo n.º 1
0
        public void SendTransferTo(AccountNumber targetAccountNumber, Amount amount)
        {
            Guard();

            IsBalanceHighEnough(amount);

            var newBalance = _balance.Withdrawl(amount);

            Apply(new MoneyTransferSendEvent(newBalance, amount, _accountNumber.Number, targetAccountNumber.Number));
        }
Exemplo n.º 2
0
        public ClosedAccount()
        {
            Id             = Guid.Empty;
            _accountName   = new AccountName(string.Empty);
            _accountNumber = new AccountNumber(string.Empty);
            Version        = 0;
            EventVersion   = 0;
            _ledgers       = new List <Ledger>();

            registerEvents();
        }
Exemplo n.º 3
0
        public ActiveAccount()
        {
            Id             = Guid.Empty;
            Version        = 0;
            EventVersion   = 0;
            _accountName   = new AccountName(string.Empty);
            _accountNumber = new AccountNumber(string.Empty);
            _balance       = new Balance();
            _ledgers       = new List <Ledger>();
            _closed        = false;

            registerEvents();
        }
Exemplo n.º 4
0
        private void onClosedAccountCreated(ClosedAccountCreatedEvent closedAccountCreatedEvent)
        {
            Id = closedAccountCreatedEvent.AccountId;
            _originalAccountId = closedAccountCreatedEvent.OriginalAccountId;
            _clientId          = closedAccountCreatedEvent.ClientId;
            _accountName       = new AccountName(closedAccountCreatedEvent.AccountName);
            _accountNumber     = new AccountNumber(closedAccountCreatedEvent.AccountNumber);

            foreach (var ledger in closedAccountCreatedEvent.Ledgers)
            {
                var split   = ledger.Value.Split(new[] { '|' });
                var amount  = new Amount(Convert.ToDecimal(split[0]));
                var account = new AccountNumber(split[1]);
                _ledgers.Add(InstantiateClassFromStringValue <Ledger>(ledger.Key, amount, account));
            }
        }
Exemplo n.º 5
0
        void IOrginator.SetMemento(IMemento memento)
        {
            var closedAccountMemento = (ClosedAccountMemento)memento;

            Id                 = closedAccountMemento.Id;
            Version            = closedAccountMemento.Version;
            _originalAccountId = closedAccountMemento.OriginalAccountId;
            _clientId          = closedAccountMemento.ClientId;
            _accountName       = new AccountName(closedAccountMemento.AccountName);
            _accountNumber     = new AccountNumber(closedAccountMemento.AccountNumber);

            foreach (var ledger in closedAccountMemento.Ledgers)
            {
                var split   = ledger.Value.Split(new[] { '|' });
                var amount  = new Amount(Convert.ToDecimal(split[0]));
                var account = new AccountNumber(split[1]);
                _ledgers.Add(InstantiateClassFromStringValue <Ledger>(ledger.Key, amount, account));
            }
        }
Exemplo n.º 6
0
 public static ClosedAccount CreateNew(Guid accountId, Guid clientId, List <Ledger> ledgers, AccountName accountName, AccountNumber accountNumber)
 {
     return(new ClosedAccount(accountId, clientId, ledgers, accountName.Name, accountNumber.Number));
 }