コード例 #1
0
 public override void StateChangeCheck(BankAccount bankAccount)
 {
     if (bankAccount.Balance < this.LowerLimit)
     {
         bankAccount.AccountStateId = GoldState.GetInstance().AccountStateId;
     }
 }
コード例 #2
0
ファイル: BITBanking.cs プロジェクト: Bgood92/bank-of-bit
 /// <summary>
 /// Checks if the balance is less than the lower limit - If so, change the state to Gold
 /// </summary>
 /// <param name="bankAccount">Evaluates the bankAccount.Balance</param>
 public override void StateChangeCheck(BankAccount bankAccount)
 {
     if (!bankAccount.Description.Equals("Mortgage"))
     {
         if (bankAccount.Balance < LOWER_LIMIT)
         {
             bankAccount.AccountStateId = GoldState.GetInstance().AccountStateId;
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Checks the current state and matches it with silverste requiremnets
 /// </summary>
 /// <param name="bankAccount"></param>
 public override void StateChangeCheck(BankAccount bankAccount)
 {
     //Checks if balance is lower than the lower limit
     if (bankAccount.Balance < LowerLimit)
     {
         bankAccount.AccountStateId = BronzeState.GetInstance().AccountStateId;
     }
     //Checks if balance is more than upper limit
     if (bankAccount.Balance > this.UpperLimit)
     {
         bankAccount.AccountStateId = GoldState.GetInstance().AccountStateId;
     }
 }
コード例 #4
0
ファイル: BITBanking.cs プロジェクト: Bgood92/bank-of-bit
        /// <summary>
        /// Returns an instance of the GoldState
        /// </summary>
        /// <returns>GoldState</returns>
        public static GoldState GetInstance()
        {
            if (goldState == null)
            {
                goldState = db.GoldStates.SingleOrDefault();

                if (goldState == null)
                {
                    goldState = new GoldState();
                    db.GoldStates.Add(goldState);
                    db.SaveChanges();
                }
            }
            return(goldState);
        }
コード例 #5
0
        /// <summary>
        /// Gets an instance of a gold state (singleton pattern)
        /// </summary>
        public static GoldState GetInstance()
        {
            BankOfBITContext db = new BankOfBITContext();

            //Checks if gold state has a value
            if (goldState == null)
            {
                goldState = db.GoldStates.SingleOrDefault();

                if (goldState == null)
                {
                    goldState = new GoldState();
                    goldState = db.GoldStates.Add(goldState);
                    db.SaveChanges();
                }
            }
            return(goldState);
        }