@@ -34,45 +34,32 @@ namespace Point85.ShiftSharp.Schedule
3434 public class NonWorkingPeriod : Named , IComparable < NonWorkingPeriod >
3535 {
3636 // owning work schedule
37- private WorkSchedule workSchedule ;
37+ public WorkSchedule WorkSchedule { get ; internal set ; }
3838
3939 // starting date and time of day
40- private LocalDateTime startDateTime ;
40+ public LocalDateTime StartDateTime { get ; set ; }
4141
4242 // duration of period
43- private Duration duration ;
43+ public Duration Duration ;
4444
4545 public NonWorkingPeriod ( ) : base ( )
4646 {
4747 }
4848
4949 internal NonWorkingPeriod ( string name , string description , LocalDateTime startDateTime , Duration duration ) : base ( name , description )
50- {
51- SetStartDateTime ( startDateTime ) ;
52- SetDuration ( duration ) ;
53- }
54-
55- /// <summary>
56- /// Get period start date and time
57- /// </summary>
58- /// <returns>Start date and time</returns>
59- public LocalDateTime GetStartDateTime ( )
60- {
61- return startDateTime ;
62- }
63-
64- /// <summary>
65- /// Set period start date and time
66- /// </summary>
67- /// <param name="startDateTime">Period start</param>
68- public void SetStartDateTime ( LocalDateTime startDateTime )
6950 {
7051 if ( startDateTime == null )
7152 {
7253 throw new Exception ( WorkSchedule . GetMessage ( "start.not.defined" ) ) ;
7354 }
7455
75- this . startDateTime = startDateTime ;
56+ if ( duration == null || duration . TotalSeconds == 0 )
57+ {
58+ throw new Exception ( WorkSchedule . GetMessage ( "duration.not.defined" ) ) ;
59+ }
60+
61+ StartDateTime = startDateTime ;
62+ Duration = duration ;
7663 }
7764
7865 /// <summary>
@@ -81,30 +68,7 @@ public void SetStartDateTime(LocalDateTime startDateTime)
8168 /// <returns>Period end</returns>
8269 public LocalDateTime GetEndDateTime ( )
8370 {
84- return startDateTime . PlusSeconds ( ( long ) duration . TotalSeconds ) ;
85- }
86-
87- /// <summary>
88- /// Get period duration
89- /// </summary>
90- /// <returns>Duration</returns>
91- public Duration GetDuration ( )
92- {
93- return duration ;
94- }
95-
96- /// <summary>
97- /// Set duration
98- /// </summary>
99- /// <param name="duration">Duration</param>
100- public void SetDuration ( Duration duration )
101- {
102- if ( duration == null || duration . TotalSeconds == 0 )
103- {
104- throw new Exception ( WorkSchedule . GetMessage ( "duration.not.defined" ) ) ;
105- }
106-
107- this . duration = duration ;
71+ return StartDateTime . PlusSeconds ( ( long ) Duration . TotalSeconds ) ;
10872 }
10973
11074 /// <summary>
@@ -119,7 +83,7 @@ public override string ToString()
11983
12084 try
12185 {
122- text = base . ToString ( ) + ", " + start + ": " + GetStartDateTime ( ) + " (" + GetDuration ( ) + ")" + ", " + end
86+ text = base . ToString ( ) + ", " + start + ": " + StartDateTime + " (" + Duration + ")" + ", " + end
12387 + ": " + GetEndDateTime ( ) ;
12488 }
12589 catch ( Exception )
@@ -136,21 +100,7 @@ public override string ToString()
136100 /// <returns>negative if less than, 0 if equal and positive if greater than</returns>
137101 public int CompareTo ( NonWorkingPeriod other )
138102 {
139- return GetStartDateTime ( ) . CompareTo ( other . GetStartDateTime ( ) ) ;
140- }
141-
142- /// <summary>
143- /// Get the work schedule that owns this non-working period
144- /// </summary>
145- /// <returns></returns>
146- public WorkSchedule GetWorkSchedule ( )
147- {
148- return workSchedule ;
149- }
150-
151- internal void SetWorkSchedule ( WorkSchedule workSchedule )
152- {
153- this . workSchedule = workSchedule ;
103+ return StartDateTime . CompareTo ( other . StartDateTime ) ;
154104 }
155105
156106 /// <summary>
@@ -162,7 +112,7 @@ public bool IsInPeriod(LocalDate day)
162112 {
163113 bool isInPeriod = false ;
164114
165- LocalDate periodStart = GetStartDateTime ( ) . Date ;
115+ LocalDate periodStart = StartDateTime . Date ;
166116 LocalDate periodEnd = GetEndDateTime ( ) . Date ;
167117
168118 if ( day . CompareTo ( periodStart ) >= 0 && day . CompareTo ( periodEnd ) <= 0 )
0 commit comments