//Changes the state if the account balance changes and if its not a mortgage account public override void StateChangeCheck(BankAccount bankAccount) { if (bankAccount.Balance < LOWER_LIMIT && !bankAccount.Description.Equals("Mortgage")) { bankAccount.AccountStateId = GoldState.GetInstance().AccountStateId; } }
//Checks if the State is null public static GoldState GetInstance() { if (goldState == null) { //takes the single or default value if its null goldState = db.GoldStates.SingleOrDefault(); //If the state is still null in the db, creates a new state and adds it to the database. if (goldState == null) { goldState = new GoldState(); db.AccountStates.Add(goldState); db.SaveChanges(); } } return(goldState); }