public override string ToString() { if (Items.Count == 0) { return("<empty>"); } List <WorkingScheduleItemDto> items = new List <WorkingScheduleItemDto>(); foreach (WorkingScheduleItemDto realItem in Items) { WorkingScheduleItemDto item = items.FirstOrDefault(i => i.StartTime == realItem.StartTime && i.EndTime == realItem.EndTime); if (item != null) { item.WeekDay = item.WeekDay + "," + realItem.WeekDay.Substring(0, 3); } else { items.Add(new WorkingScheduleItemDto() { StartTime = realItem.StartTime, EndTime = realItem.EndTime, WeekDay = realItem.WeekDay.Substring(0, 3), }); } } return(String.Join(";", items.Select(i => String.Format("{0} ({1}:{2}-{3}:{4})", i.WeekDay, i.StartTime.Hour, i.StartTime.Minute, i.EndTime.Hour, i.EndTime.Minute)).ToArray())); }
public bool DiffersFrom(WorkingScheduleItemDto item) { return(item.IsActive != IsActive || item.StartTime != StartTime || item.EndTime != EndTime || item.BreakTo != BreakTo || item.BreakFrom != BreakFrom || item.ModalityId != ModalityId || item.WeekDay != WeekDay); }
public WorkingScheduleItemDto(WorkingScheduleItemDto item) { Id = item.Id; ModalityId = item.Id; WeekDay = item.WeekDay; StartTime = item.StartTime; EndTime = item.EndTime; BreakFrom = item.BreakFrom; BreakTo = item.BreakTo; IsActive = item.IsActive; }
public WorkingScheduleItemDto GetScheduleForDay(DateTime day) { WorkingScheduleItemDto sched = GetScheduleForHoliday(day); if (sched == null) { sched = GetScheduleForDay(day.DayOfWeek); } if (sched != null) { sched = new WorkingScheduleItemDto(sched); sched.StartTime = day.Date + sched.StartTime.TimeOfDay; sched.EndTime = day.Date + sched.EndTime.TimeOfDay; } return(sched); }
public bool Contains(WorkingScheduleItemDto schedule) { long smallStart = schedule.StartTime.Hour * 60 + schedule.StartTime.Minute; long smallEnd = schedule.EndTime.Hour * 60 + schedule.EndTime.Minute; long start = this.StartTime.Hour * 60 + this.StartTime.Minute; long end = this.EndTime.Hour * 60 + this.EndTime.Minute; if (this.BreakFrom.HasValue && this.BreakTo.HasValue) { long breakStart = this.BreakFrom.Value.Hour * 60 + this.BreakFrom.Value.Minute; long breakEnd = this.BreakTo.Value.Hour * 60 + this.BreakTo.Value.Minute; return((start <= smallStart && breakStart >= smallEnd) || (breakEnd <= smallStart && end >= smallEnd));; } else { return(start <= smallStart && end >= smallEnd); } }
public bool DiffersFrom(WorkingScheduleDto workingSchedule) { if (workingSchedule == null) { return(true); } if (workingSchedule.Items != null || this.Items != null) { if (workingSchedule.Items == null) { return(true); } if (Items.Count != workingSchedule.Items.Count) { return(true); } foreach (WorkingScheduleItemDto thisItem in Items) { WorkingScheduleItemDto item = workingSchedule.GetScheduleForDay(thisItem.WeekDay); if (item == null) { return(true); } if (item.DiffersFrom(thisItem)) { return(true); } } } if (this.Holidays.Count != workingSchedule.Holidays.Count) { return(true); } foreach (HolidayDto holiday in workingSchedule.Holidays) { if (!this.Holidays.Contains <HolidayDto>(holiday, HolidayComparer.Instance)) { return(true); } } return(false); }
private WorkingScheduleItemDto GetScheduleForHoliday(DateTime day) { WorkingScheduleItemDto holiday = Items.FirstOrDefault(h => h.WeekDay == day.Date.ToString("yyyy-MM-dd")); return(holiday); }