public void Add(StudentExpectedAttendanceEntry entry) { if (entry.iStudentID == this.iStudentID) { if (entry.BlocksToday > 0) { if (!this._attendanceArray.ContainsKey(entry.Date.Year)) { this._attendanceArray.Add(entry.Date.Year, new Dictionary <int, Dictionary <int, int> >()); } if (!this._attendanceArray[entry.Date.Year].ContainsKey(entry.Date.Month)) { this._attendanceArray[entry.Date.Year].Add(entry.Date.Month, new Dictionary <int, int>()); } if (!this._attendanceArray[entry.Date.Year][entry.Date.Month].ContainsKey(entry.Date.Day)) { this._attendanceArray[entry.Date.Year][entry.Date.Month].Add(entry.Date.Day, 0); } if (this._attendanceArray[entry.Date.Year][entry.Date.Month][entry.Date.Day] < entry.BlocksToday) { this._attendanceArray[entry.Date.Year][entry.Date.Month][entry.Date.Day] += entry.BlocksToday; } } } else { throw new Exception("Cannot add expected attendance from another student"); } }
public UpdateCheck CheckIfUpdatesAreRequired(StudentExpectedAttendanceEntry obj) { // For this object, the "ID" is every field except blockstoday if ( (this.iStudentID != obj.iStudentID) || (this.Date.Year != obj.Date.Year) || (this.Date.Month != obj.Date.Month) || (this.Date.Date != obj.Date.Date) ) { return(UpdateCheck.NotSameObject); } // Check all properties of the objects to see if they are different int updates = 0; if (!this.BlocksToday.Equals(obj.BlocksToday)) { updates++; } if (updates == 0) { return(UpdateCheck.NoUpdateRequired); } else { return(UpdateCheck.UpdatesRequired); } }