public void ShowError(string errorMessage)
 {
     if (MonoSingleton <NativeAccessibilityManager> .Instance.Native.GetAccessibilityLevel() > 0)
     {
         HasError = true;
     }
     OnValidationError.Invoke(errorMessage);
 }
Example #2
0
        public bool MakePayment(string paymentName, decimal amount, Account backupAccount = null)
        {
            if (amount <= 0)
            {
                ValidationEvent?.Invoke(this, "You try to Pay 0. Are you kidding ?");
                return(false);
            }
            // Ensures we have enough money
            if (Balance >= amount)
            {
                _transactions.Add($"Withdrew { string.Format("{0:C2}", amount) } for { paymentName }");
                Balance -= amount;
                TransactionApprovedEvent?.Invoke(this, paymentName);
                return(true);
            }
            else
            {
                // We don't have enough money so we check to see if we have a backup account
                if (backupAccount != null)
                {
                    // Checks to see if we have enough money in the backup account
                    if ((backupAccount.Balance + Balance) >= amount)
                    {
                        // We have enough backup funds so transfar the amount to this account
                        // and then complete the transaction.
                        decimal amountNeeded       = amount - Balance;
                        bool    overdraftSucceeded = backupAccount.MakePayment("Overdraft Protection", amountNeeded);

                        // This should always be true but we will check anyway
                        if (overdraftSucceeded == false)
                        {
                            ValidationEvent?.Invoke(this, "The overdraft failed so this transaction failed");
                            return(false);
                        }

                        AddDeposit("Overdraft Protection Deposit", amountNeeded);

                        _transactions.Add($"Withdrew { string.Format("{0:C2}", amount) } for { paymentName }");
                        Balance -= amount;
                        TransactionApprovedEvent?.Invoke(this, paymentName);
                        OverdraftEvent?.Invoke(this, new OverDraftEventArgs(amountNeeded, "Extra Info"));

                        return(true);
                    }
                    else
                    {
                        ValidationEvent?.Invoke(this, "Not enough backup funds to do anything");
                        return(false);
                    }
                }
                else
                {
                    ValidationEvent?.Invoke(this, "You don't have enough money in the backup account");
                    return(false);
                }
            }
        }
 public void ShowError(string errorMessage)
 {
     OnValidationError.Invoke(errorMessage);
 }
Example #4
0
 public void InvokeValidationEvent()
 {
     ValidationEvent.Invoke();
 }
Example #5
0
        //private void Validate(object s, ValidationEventArgs e)
        //{
        //    Validated = e.PlanesToValidate;
        //    int[] stats = _airspace.getAirspaceLimits();

        //    foreach (Airplane data in e.PlanesToValidate)
        //    {


        //        if (stats[0] > data._xCoordiante && stats[1] < data._xCoordiante)
        //        {
        //            if (stats[2] > data._yCoordiante && stats[3] < data._yCoordiante)
        //            {
        //                if (stats[4] > data._Altitude && stats[5] < data._Altitude)
        //                {
        //                    Validated.Add(data);
        //                }
        //            }
        //        }
        //    }

        //    if (Validated != e.PlanesToValidate)
        //    {
        //        OnCheckSeperationCondition(new PlaneConditionCheckedEventArgs(Validated), new LogSeperationEventArgs(Validated));
        //    }
        //}

        protected virtual void OnCheckSeperationCondition(ValidationEventArgs event_)
        {
            ValidationEvent?.Invoke(this, event_);
            //Console.WriteLine("tis");
        }