Example #1
0
 //Changes the state if the account balance changes and if its not a mortgage account
 public override void StateChangeCheck(BankAccount bankAccount)
 {
     if (bankAccount.Balance > UPPER_LIMIT && !bankAccount.Description.Equals("Mortgage"))
     {
         bankAccount.AccountStateId = SilverState.GetInstance().AccountStateId;
     }
 }
Example #2
0
        //Checks if the State is null
        public static SilverState GetInstance()
        {
            if (silverState == null)
            {
                //takes the single or default value if its null
                silverState = db.SilverStates.SingleOrDefault();

                //If the state is still null in the db, creates a new state and adds it to the database.
                if (silverState == null)
                {
                    silverState = new SilverState();
                    db.AccountStates.Add(silverState);
                    db.SaveChanges();
                }
            }
            return(silverState);
        }