コード例 #1
0
ファイル: BITBanking.cs プロジェクト: Bgood92/bank-of-bit
 /// <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;
         }
     }
 }
コード例 #2
0
        /// <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;
            }
        }
コード例 #3
0
ファイル: BITBanking.cs プロジェクト: Bgood92/bank-of-bit
        /// <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);
        }