internal Program(ProgramConfig programConfig) { Id = Guid.NewGuid(); Name = programConfig.Name; foreach (var config in programConfig.CycleConfigs) { _cycles.AddRange(WateringCycle.ToWateringCycles(this, config)); } }
internal bool ConflictsWith(WateringCycle cycle) { if (EndMinuteOfWeek > StartMinuteOfWeek && cycle.EndMinuteOfWeek > cycle.StartMinuteOfWeek) { return(RangeOverlaps(StartMinuteOfWeek, EndMinuteOfWeek, cycle.StartMinuteOfWeek, cycle.EndMinuteOfWeek)); } else if (EndMinuteOfWeek > StartMinuteOfWeek && cycle.EndMinuteOfWeek < cycle.StartMinuteOfWeek) { return(cycle.EndMinuteOfWeek >= StartMinuteOfWeek || cycle.StartMinuteOfWeek <= EndMinuteOfWeek); } else if (EndMinuteOfWeek < StartMinuteOfWeek && cycle.EndMinuteOfWeek > cycle.StartMinuteOfWeek) { return(cycle.StartMinuteOfWeek <= EndMinuteOfWeek || cycle.EndMinuteOfWeek >= StartMinuteOfWeek); } else { return(true); } }