// for creates // throws event doesn't exist exception // throws not found exception // throws attendeeOverlay public static void AttendeeOverlay(DateTime?start, DateTime?end, IList <EventAttendee> eventAttendees, string calendarId) { // tests if there are attendees added if (eventAttendees == null) { // no attendees == no tests needed = no overlay return; } // can throw event doesn't exist exception var events = Eventss.IgetAllNotDeletedEvent(calendarId); // tests if there are any events if (events != null) { foreach (var ev in events.Items) { foreach (var attendee in eventAttendees) { // tests the overlay if (ev.Attendees != null && ev.Attendees.Contains(attendee)) { // tests the overlay if (Math.Max(end.Value.Ticks, ev.End.DateTime.Value.Ticks) - Math.Min(start.Value.Ticks, ev.Start.DateTime.Value.Ticks) < (end.Value.Ticks - start.Value.Ticks) + (ev.End.DateTime.Value.Ticks - ev.Start.DateTime.Value.Ticks)) { // overlay throw new AttendeeOverlayException("attendee overlay"); } } } } } // there are no events = no test needed = no overlay return; }
// for updated // throws event doesn't exist exception // throws not found exception // throws locationOverlay public static void LocationOverlay(DateTime?start, DateTime?end, string location, string calendarId, string eventId) { // can throw event doesn't exist exception var events = Eventss.IgetAllNotDeletedEvent(calendarId); // tests if there are any events if (events != null) { foreach (Event ev in events.Items) { // tests the overlay if (ev.Location == location) { // tests the overlay if (Math.Max(end.Value.Ticks, ev.End.DateTime.Value.Ticks) - Math.Min(start.Value.Ticks, ev.Start.DateTime.Value.Ticks) < (end.Value.Ticks - start.Value.Ticks) + (ev.End.DateTime.Value.Ticks - ev.Start.DateTime.Value.Ticks)) { // makes sure the overlay is not from the notUpdated version of the event if (eventId != ev.Id) { // overlay throw new LocationOverlayException("there is an location overlay"); } } } } } // there are no events = no test needed = no overlay return; }