/// <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> /// Checks if the balance is greater than the upper limit - If so, change the state to gold /// Checks if the balance is less than the lower limit - If so, change the state to bronze /// </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 = GoldState.GetInstance().AccountStateId; } else if (bankAccount.Balance < LOWER_LIMIT) { bankAccount.AccountStateId = BronzeState.GetInstance().AccountStateId; } } }
/// <summary> /// Checks if there is a record of the bronze state in the database, /// if there is one, it returns it, if there is not, it creates one /// </summary> /// <returns>The bronze state found or created</returns> public static BronzeState GetInstance() { BankOfBITContext db = new BankOfBITContext(); if (bronzeState == null) { bronzeState = db.BronzeStates.SingleOrDefault(); if (bronzeState == null) { bronzeState = new BronzeState(); bronzeState = db.BronzeStates.Add(bronzeState); db.SaveChanges(); } } return(bronzeState); }
/// <summary> /// Returns an instance of the BronzeState /// </summary> /// <returns>bronzeState</returns> public static BronzeState GetInstance() { //Checks if there is already an instance of BronzeState if (bronzeState == null) { //Retrieves the instance of BronzeState from the BronzeStates table or null bronzeState = db.BronzeStates.SingleOrDefault(); if (bronzeState == null) { //Creates a new BronzeState object and adds it to the database //Save changes to the database bronzeState = new BronzeState(); db.BronzeStates.Add(bronzeState); db.SaveChanges(); } } return(bronzeState); }