private void DoSetParticipants(Itinerary itinerary, ItineraryParticipants itineraryParticipants, IEnumerable <int> itineraryStopParticipantsById, IEnumerable <int> nonPersonParticipantsById) { var orphanedItineraryStopParticipantsById = itineraryStopParticipantsById.Except(itineraryParticipants.ParticipantIds).ToList(); itineraryParticipantsValidator.ValidateUpdate(new ItineraryParticipantsValidationEntity( orphanedParticipantsByParticipantId: orphanedItineraryStopParticipantsById, nonPersonParticipantsByParticipantIds: nonPersonParticipantsById )); itineraryParticipants.Audit.SetHistory(itinerary); SetParticipants(itineraryParticipants.ParticipantIds.ToList(), itinerary, x => x.Participants); }
/// <summary> /// Sets the participants on the itinerary. /// </summary> /// <param name="itineraryParticipants">The business entity containing the participants by id that should be set on the itinerary.</param> public void SetParticipants(ItineraryParticipants itineraryParticipants) { var itineraryToUpdate = Context.Itineraries.Find(itineraryParticipants.ItineraryId); throwIfModelDoesNotExist(itineraryParticipants.ItineraryId, itineraryToUpdate, typeof(Itinerary)); throwSecurityViolationIfDifferentProject(itineraryParticipants.Audit.User.Id, itineraryToUpdate, itineraryParticipants.ProjectId); var projectParticipantIds = CreateGetParticipantsByParticipantIdsAndProjectIdQuery(itineraryParticipants.ParticipantIds, itineraryParticipants.ProjectId).Select(x => x.ParticipantId).ToList(); var participantsByIdThatDoNotExist = GetIdsOfParticipantsThatDoNotExist(itineraryParticipants.ParticipantIds, projectParticipantIds); throwSecurityViolationIfParticipantsNotOnProject(itineraryParticipants.Audit.User.Id, participantsByIdThatDoNotExist, itineraryParticipants.ItineraryId, itineraryToUpdate.ProjectId); var itineraryStopParticipantsById = CreateGetItineraryStopParticipantsByItineraryIdQuery(itineraryParticipants.ItineraryId).Select(x => x.ParticipantId).ToList(); var nonPersonParticipantsById = CreateGetParticipantsThatAreNotPeopleQuery(itineraryParticipants.ParticipantIds).Select(x => x.ParticipantId).ToList(); DoSetParticipants( itinerary: itineraryToUpdate, itineraryParticipants: itineraryParticipants, itineraryStopParticipantsById: itineraryStopParticipantsById, nonPersonParticipantsById: nonPersonParticipantsById ); }
/// <summary> /// /// </summary> /// <param name="itineraryParticipants"></param> /// <returns></returns> public Task SetParticipantsAsync(ItineraryParticipants itineraryParticipants) { Contract.Requires(itineraryParticipants != null, "The itinerary participants must not be null."); return(Task.FromResult <object>(null)); }
/// <summary> /// /// </summary> /// <param name="itineraryParticipants"></param> public void SetParticipants(ItineraryParticipants itineraryParticipants) { Contract.Requires(itineraryParticipants != null, "The itinerary participants must not be null."); }