/// <summary>
        /// Creates a new itinerary stop.
        /// </summary>
        /// <param name="addedStop">The new itinerary stop.</param>
        /// <returns>The Eca.Data ItineraryStop instance.</returns>
        public async Task <ItineraryStop> CreateAsync(AddedEcaItineraryStop addedStop)
        {
            var itinerary = await Context.Itineraries.FindAsync(addedStop.ItineraryId);

            throwIfModelDoesNotExist(addedStop.ItineraryId, itinerary, typeof(Itinerary));
            throwSecurityViolationIfDifferentProject(addedStop.Audit.User.Id, itinerary, addedStop.ProjectId);

            var destination = await Context.Locations.FindAsync(addedStop.DestinationLocationId);

            throwIfModelDoesNotExist(addedStop.DestinationLocationId, destination, typeof(Location));

            return(DoCreate(itinerary, addedStop));
        }
        private ItineraryStop DoCreate(Itinerary itinerary, AddedEcaItineraryStop addedStop)
        {
            var validationEntity = GetEcaItineraryStopValidationEntity(itinerary: itinerary, ecaitineraryStop: addedStop);

            itineraryStopValidator.ValidateCreate(validationEntity);

            var update = new Update(addedStop.Audit.User);

            update.SetHistory(itinerary);

            var itineraryStop = new ItineraryStop();

            itineraryStop.DateArrive        = addedStop.ArrivalDate;
            itineraryStop.DateLeave         = addedStop.DepartureDate;
            itineraryStop.DestinationId     = addedStop.DestinationLocationId;
            itineraryStop.ItineraryId       = addedStop.ItineraryId;
            itineraryStop.ItineraryStatusId = ItineraryStatus.InProgress.Id;
            itineraryStop.Name       = addedStop.Name;
            itineraryStop.TimezoneId = addedStop.TimezoneId;
            addedStop.Audit.SetHistory(itineraryStop);

            Context.ItineraryStops.Add(itineraryStop);
            return(itineraryStop);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="addedStop"></param>
 /// <returns></returns>
 public ItineraryStop Create(AddedEcaItineraryStop addedStop)
 {
     Contract.Requires(addedStop != null, "The stop must not be null.");
     return(null);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="addedStop"></param>
 /// <returns></returns>
 public Task <ItineraryStop> CreateAsync(AddedEcaItineraryStop addedStop)
 {
     Contract.Requires(addedStop != null, "The stop must not be null.");
     return(Task.FromResult <ItineraryStop>(null));
 }