// Updating period will require end date to recalculate public void updatePeriod(contrPeriod newPeriod) { if (newPeriod.Equals(this.period)) { return; } this.changed = true; this.period = newPeriod; this.endDate = this.calcEndDate(); }
// Update contrAmt and change to a new contrPeriod, require both numPeriods and endDate to recalculate public void updateContrAmtAndPeriod(decimal newContrAmt, contrPeriod newPeriod) { if (newContrAmt == this.contrAmt && newPeriod.Equals(this.period)) { return; } this.changed = true; this.contrAmt = newContrAmt; this.period = newPeriod; this.numPeriods = this.calcPeriodsWithAmt(); this.endDate = this.calcEndDate(); }
// Constructor: reinstantiate a pre-existing SavingsGoal from database records public SavingsGoal(long SGID, long accID, string name, decimal goalAmt, decimal contrAmt, contrPeriod period, long numPeriods, DateTime startDate, DateTime endDate) { this.SGID = SGID; this.accID = accID; this.name = name; this.goalAmt = goalAmt; this.contrAmt = contrAmt; this.period = period; this.numPeriods = numPeriods; this.startDate = startDate; this.endDate = endDate; this.newlyCreated = this.changed = false; }
// ---------------------------------------- SavingsGoal Constructors ----------------------------------- // Constructor: create SavingsGoal by endDate public SavingsGoal(long SGID, long accID, string name, decimal goalAmt, contrPeriod period, DateTime endDate) { this.SGID = SGID; this.accID = accID; this.name = name; this.goalAmt = goalAmt; this.period = period; this.startDate = DateTime.Now.Date; this.newlyCreated = true; this.endDate = endDate.Date; this.numPeriods = calcPeriodsWithDate(); this.contrAmt = calcContrAmt(); }