public void HandleOnUserBalanceNotification(Object sender, LowBalanceEventArgs e)
 {
     if (e.User.LowBalanceDefinition > e.User.Balance)
     {
         UI.DisplayLowUserBalance(e.User);
     }
     else
     {
         UI.DisplayUserBalanceNormalised(e.User);
     }
 }
Exemple #2
0
        public void ExecuteTransaction(Transaction transaction)
        {
            try
            {
                transaction.Execute();

                ExecutedTransactions.Add(transaction);

                if (transaction.User.Balance - transaction.Amount < transaction.User.LowBalanceDefinition &&
                    transaction.User.Balance + transaction.Amount >= transaction.User.LowBalanceDefinition)
                {
                    LowBalanceEventArgs args = new LowBalanceEventArgs();
                    args.User        = transaction.User;
                    args.TimeReached = DateTime.UtcNow;
                    OnUserBalanceNotification(args);
                }

                if (transaction.User.Balance < transaction.User.LowBalanceDefinition)
                {
                    LowBalanceEventArgs args = new LowBalanceEventArgs();
                    args.User        = transaction.User;
                    args.TimeReached = DateTime.UtcNow;
                    OnUserBalanceNotification(args);
                }
            }
            catch (InsufficientCreditsException e)
            {
                throw e;
            }
            catch (ProductNotActivatedException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #3
0
 protected virtual void OnUserBalanceNotification(LowBalanceEventArgs e)
 {
     UserBalanceWarning?.Invoke(this, e);
 }