public void Credit(decimal amount, string type, CorrelatedMessage source)
        {
            if (amount <= 0)
            {
                throw new ValidationException("Cannot deposit a negative amount");
            }

            if (type.ToLower().Contains("cash"))
            {
                var cashDeposited = new AccountCashDepositedEvent(source)
                {
                    AccountId = Id,
                    Amount    = amount
                };
                Raise(cashDeposited);
                if (State.ToLower() == "blocked" && Balance >= 0)
                {
                    var unblocked = new AccountUnblockedEvent(source)
                    {
                        AccountId    = Id,
                        AccountState = "Active"
                    };
                    Raise(unblocked);
                }
            }
            else if (type.ToLower().Contains("check"))
            {
                var checkDeposited = new AccountCheckDepositedEvent(source)
                {
                    AccountId  = Id,
                    Amount     = amount,
                    CreditDate = DateTime.UtcNow
                };
                Raise(checkDeposited);
                if (State.ToLower() == "blocked" && Balance >= 0)
                {
                    var unblocked = new AccountUnblockedEvent(source)
                    {
                        AccountId    = Id,
                        AccountState = "Active"
                    };
                    Raise(unblocked);
                }
            }
        }
        public void SetDailyWireTransferLimit(decimal dailyWireTransferLimit, CorrelatedMessage source)
        {
            if (dailyWireTransferLimit < 0)
            {
                throw new ValidationException("dailyWireTransfer limit cannot be negative");
            }
            if (State.ToLower() == "blocked" && _withdrawnToday <= DailyWireTransferLimit && dailyWireTransferLimit > DailyWireTransferLimit)
            {
                var unblocked = new AccountUnblockedEvent(source)
                {
                    AccountId    = Id,
                    AccountState = "Active"
                };
                Raise(unblocked);
            }
            var dailyWireTransferLimitSet = new DailyWireTransferLimitSetEvent(source)
            {
                AccountId = Id,
                DailyWireTransferLimit = dailyWireTransferLimit
            };

            Raise(dailyWireTransferLimitSet);
        }
Example #3
0
 public void Handle(AccountUnblockedEvent message)
 {
     state = message.AccountState;
     Accounts.First(acct => acct.Id == message.AccountId.ToString()).State = state;
     redraw();
 }
 private void Apply(AccountUnblockedEvent unblockedEvent)
 {
     State = unblockedEvent.AccountState;
 }
 public void Apply(AccountUnblockedEvent @event)
 {
     AccountState = Enumerations.AccountState.Actif;
 }
 public Task Handle(AccountUnblockedEvent message, IMessageHandlerContext context)
 {
     throw new NotImplementedException();
 }