public override void StateChangeCheck(BankAccount bankAccount) { if (bankAccount.Balance < this.LowerLimit) { bankAccount.AccountStateId = GoldState.GetInstance().AccountStateId; } }
/// <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; } } }
/// <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; } }
/// <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); }
/// <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); }