Example #1
0
 /// <summary>
 /// Checks if the balance is greater than the upper limit - If so, change the state to Platinum
 /// Checks if the balance is less than the lower limit - If so, change the state to Silver
 /// </summary>
 /// <param name="bankAccount">Evaluates the bankAccount.Balance</param>
 public override void StateChangeCheck(BankAccount bankAccount)
 {
     if (!bankAccount.Description.Equals("Mortgage"))
     {
         if (bankAccount.Balance > UPPER_LIMIT)
         {
             bankAccount.AccountStateId = PlatinumState.GetInstance().AccountStateId;
         }
         else if (bankAccount.Balance < LOWER_LIMIT)
         {
             bankAccount.AccountStateId = SilverState.GetInstance().AccountStateId;
         }
     }
 }
        /// <summary>
        /// Setting the current state to the right one
        /// </summary>
        /// <param name="bankAccount"></param>
        public override void StateChangeCheck(BankAccount bankAccount)
        {
            //Checks if balance is less than lower limit
            if (bankAccount.Balance < this.LowerLimit)
            {
                bankAccount.AccountStateId = SilverState.GetInstance().AccountStateId;
            }

            //Checks if balance is more than upper limit
            if (bankAccount.Balance > this.UpperLimit)
            {
                bankAccount.AccountStateId = PlatinumState.GetInstance().AccountStateId;
            }
        }
Example #3
0
        /// <summary>
        /// Returns an instance of the PlatinumState
        /// </summary>
        /// <returns>PlatinumState</returns>
        public static PlatinumState GetInstance()
        {
            if (platinumState == null)
            {
                platinumState = db.PlatinumStates.SingleOrDefault();

                if (platinumState == null)
                {
                    platinumState = new PlatinumState();
                    db.PlatinumStates.Add(platinumState);
                    db.SaveChanges();
                }
            }
            return(platinumState);
        }