private static bool ReplacementIsPossible(Time newBeginTime, Time newEndTime, Guid newTherapyplaceId, Guid originalAppointmentId, FixedAppointmentSet sourceAppointmentSet, FixedAppointmentSet destinationAppointmentSet) { return(DeletionPossible(originalAppointmentId, sourceAppointmentSet) && AddingIsPossible(newTherapyplaceId, originalAppointmentId, newBeginTime, newEndTime, destinationAppointmentSet)); }
private static bool AddingIsPossible(Guid therapyPlaceId, Guid appointmentId, Time startTime, Time endTime, FixedAppointmentSet appointmentSet) { return(appointmentSet.Appointments .Where(appointment => appointment.TherapyPlace.Id == therapyPlaceId) .Where(appointment => appointment.Id != appointmentId) .All(appointment => (appointment.StartTime <= startTime || appointment.StartTime >= endTime) && (appointment.EndTime <= startTime || appointment.EndTime >= endTime))); }
private static bool DeletionPossible(Guid appointmentId, FixedAppointmentSet appointmentSet) { return(appointmentSet.Appointments.Any(appointment => appointment.Id == appointmentId)); }