public virtual TimeSpan GetSpan(DateTime start, DateTime end) { TimeSpan result = (end - start).Add(new TimeSpan(1, 0, 0, 0)); IWorkDay[] spcDays = GetSpecialDays(start, end); int days = (int)result.TotalDays; IWorkDay day = null; for (int i = 0; i < days; i++) { DateTime tmp = start.AddDays(i); if (spcDays != null) { day = (from t in spcDays where t.Day.Date == tmp.Date select t).FirstOrDefault(); } //非工作日 if (((tmp.DayOfWeek == DayOfWeek.Saturday || tmp.DayOfWeek == DayOfWeek.Sunday) && ((day == null) || !day.IsWork)) || (((tmp.DayOfWeek != DayOfWeek.Saturday && tmp.DayOfWeek != DayOfWeek.Sunday) && ((day != null) && !day.IsWork)))) { result = result.Subtract(new TimeSpan(1, 0, 0, 0)); } } return(result); }
public TimesheetDay(IWorkDay workDay) { Date = workDay.Date; StartTime = workDay.StartTime; EndTime = workDay.EndTime; BreakDuration = workDay.BreakDuration; WorkedHours = workDay.WorkedHours; OnTimesheet = true; }
public void VerifyTimes(IWorkDay workDay) { var timeSpan = workDay.EndTime.Subtract(workDay.StartTime); if (workDay.BreakDuration != TimeSpan.Zero) { timeSpan = timeSpan.Subtract(workDay.BreakDuration); } if (timeSpan != workDay.WorkedHours) { throw new ApplicationException($"Provided Duration do not match calculated value for {workDay.Date:d}"); } }
public void AddDay(IWorkDay workDay) { if (_days.Count == 7) { throw new ArgumentException("Attempt on adding more than 7 days to a week"); } if (_days.ContainsKey(workDay.Date.DayOfWeek)) { throw new ArgumentException($"{workDay.Date.DayOfWeek} already present in dictionary"); } _days.Add(workDay.Date.DayOfWeek, workDay); }
public Query(IBookAppointment bookAppointment, IProfile profile, IWorkDay workDay) { _bookAppointment = bookAppointment; _workDay = workDay; _profile = profile; }
public void AdjustTimes(IWorkDay workDay) { workDay.StartTime = RoundDownToNearestTenthMinute(workDay.StartTime); workDay.BreakDuration = RoundDownToNearestTenthMinute(workDay.BreakDuration); workDay.EndTime = GetAdjustedEndTime(workDay); }
private static TimeSpan GetAdjustedEndTime(IWorkDay workDay) { return(workDay.StartTime.Add(workDay.WorkedHours).Add(workDay.BreakDuration)); }
public Mutation(IBookAppointment bookAppointmentService, IWorkDay workDayService) { _bookAppointmentService = bookAppointmentService; _workDayService = workDayService; }
public RouterWorkDay(IWorkDay workDay, RouterMatch routerMatch) { _workDay = workDay; _routerMatch = routerMatch; }