public Vacation(Vacation copy) { if (copy.IsDateDefined) { startDate = copy.startDate; endDate = copy.endDate; } duration = copy.duration; IsDateDefined = copy.IsDateDefined; holidayManager = copy.holidayManager; RecalcDuration(); }
public Vacation CreateProperVacation(Vacation vacationBase) { Vacation derived; if (accountType == EmploymentType.IP) { derived = new VacationIp(vacationBase); } else { derived = new VacationOoo(vacationBase); } return(derived); }
public void DeleteVacation(Vacation vacation) { if (vacation.IsDateDefined) { var deleters = vacationList.Where(item => item.StartDate == vacation.StartDate && item.EndDate == vacation.EndDate); vacationList.Remove(deleters.First()); } else { var deleters = vacationList.Where(item => item.Duration == vacation.Duration); vacationList.Remove(deleters.First()); } calculator.FillEmployeeData(); }
public bool AddVacation(Vacation newVacation) { if (newVacation.IsDateDefined) { if (IsVacationInterfering(newVacation)) { return(false); } } Vacation derived = CreateProperVacation(newVacation); derived.VacationChanged += OnVacationChanged; vacationList.Add(derived); calculator.FillEmployeeData(); return(true); }
public bool ChangeEndDate(DateTime startDate, DateTime newEnd) { var oldVacationList = vacationList.Where(item => item.StartDate == startDate); Vacation newVacation = new Vacation(startDate, newEnd, ref holidayManager); Vacation oldVacationCopy = new Vacation(oldVacationList.First()); DeleteVacation(oldVacationList.First()); if (AddVacation(newVacation)) { calculator.FillEmployeeData(); return(true); } else { AddVacation(oldVacationCopy); return(false); } }
private bool IsVacationInterfering(Vacation candidate) { foreach (Vacation existing in vacationList) { if (candidate.StartDate >= existing.StartDate && candidate.StartDate <= existing.EndDate) { return(true); } if (candidate.EndDate >= existing.StartDate && candidate.EndDate <= existing.EndDate) { return(true); } if (existing.StartDate >= candidate.StartDate && existing.StartDate <= candidate.EndDate) { return(true); } if (existing.EndDate >= candidate.StartDate && existing.EndDate <= candidate.EndDate) { return(true); } } return(false); }
public bool AddVacation(int id, Vacation vacation) { return(Employees[id].AddVacation(vacation)); }
public VacationOoo(Vacation copy) : base(copy) { holidayManager.HolidaysChanged += OnHolidaysChanged; }