/// <summary> /// Updates the appointment attendees. /// </summary> /// <param name="appointmentId">The appointment identifier.</param> /// <param name="attendees">The attendees.</param> internal void UpdateAppointmentAttendees( int appointmentId, IEnumerable <string> attendees) { List <AppointmentAttendeeModel> attendeeeModels = databaseProvider.GetAppointmentAttendees(appointmentId); string[] emailAddresses = attendees as string[] ?? attendees.ToArray(); foreach (AppointmentAttendeeModel appointmentAttendeeModel in attendeeeModels) { //// if the current atteendee not in the viewModel attendees then remove from the database if (emailAddresses.Contains(appointmentAttendeeModel.Name) == false) { databaseProvider.DeleteAppointmentAttendee(appointmentAttendeeModel); } } //// now add any additional attendees foreach (string emailAddress in emailAddresses) { if (attendeeeModels.FirstOrDefault(m => m.Name == emailAddress) == null) { databaseProvider.InsertAppointmentAttendee(new AppointmentAttendeeModel { AppointmentId = appointmentId, EmailAddress = emailAddress }); } } }