Esempio n. 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 = GoldState.GetInstance().AccountStateId;
            }

            if (bankAccount.Balance < LOWER_LIMIT && !bankAccount.Description.Equals("Mortgage"))
            {
                bankAccount.AccountStateId = BronzeState.GetInstance().AccountStateId;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This method sees if there's an instance of the bronxe state , if not adds one to it
        /// </summary>
        /// <returns>the instance of bronze state</returns>
        public static BronzeState GetInstance()
        {
            //Checks if the bronze state is null
            if (bronzeState == null)
            {
                //takes the single or default value if its null
                bronzeState = db.BronzeStates.SingleOrDefault();

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

            return(bronzeState);
        }