예제 #1
0
        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);
        }
예제 #2
0
        /// <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
                );
        }
예제 #3
0
 /// <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));
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="itineraryParticipants"></param>
 public void SetParticipants(ItineraryParticipants itineraryParticipants)
 {
     Contract.Requires(itineraryParticipants != null, "The itinerary participants must not be null.");
 }