/// <summary> /// Used to Update Before doing a data save /// Updates everything except for the ID /// </summary> /// <param name="data">Data to update</param> public void Update(SchoolCalendarModel data) { if (data == null) { return; } Date = data.Date; TimeStart = data.TimeStart; TimeEnd = data.TimeEnd; DayStart = data.DayStart; DayEnd = data.DayEnd; Modified = data.Modified; SchoolDay = data.SchoolDay; HasAttendance = data.HasAttendance; if (SchoolDay) { // The time in school is the delta of end - start TimeDuration = data.TimeEnd.Subtract(TimeStart); } else { TimeDuration = TimeSpan.Zero; } //// Check to make sure not set as early or late, if the time time is changed //// This solves the issue of having an item be set as early dismissal, and then the time changed to say 14:01, but it still shows as early dismissal. //var myDefault = Backend.DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault(); //if (DayStart == SchoolCalendarDismissalEnum.Early && TimeStart != myDefault.StartEarly) //{ // DayStart = SchoolCalendarDismissalEnum.Normal; //} //if (DayStart == SchoolCalendarDismissalEnum.Late && TimeStart != myDefault.StartLate) //{ // DayStart = SchoolCalendarDismissalEnum.Normal; //} //if (DayEnd == SchoolCalendarDismissalEnum.Early && TimeEnd != myDefault.EndEarly) //{ // DayEnd = SchoolCalendarDismissalEnum.Normal; //} //if (DayEnd == SchoolCalendarDismissalEnum.Late && TimeEnd != myDefault.EndLate) //{ // DayEnd = SchoolCalendarDismissalEnum.Normal; //} //// If not a school day, then no time in class. //SetNoSchoolDayTimes(); }
/// <summary> /// Make an SchoolCalendar from values passed in /// </summary> /// <param name="data">a valid model</param> public SchoolCalendarModel(SchoolCalendarModel data) { Initialize(data.Date); if (data == null) { // If the data is null, just return a regular initialized one return; } Date = data.Date; TimeStart = data.TimeStart; TimeEnd = data.TimeEnd; DayStart = data.DayStart; DayEnd = data.DayEnd; Modified = data.Modified; SchoolDay = data.SchoolDay; TimeDuration = data.TimeEnd.Subtract(TimeStart); }