Esempio n. 1
0
 public virtual void RemoveRoutes(ItineraryRoute __item)
 {
     if (__item != null && routes != null && routes.Contains(__item))
     {
         routes.Remove(__item);
         if (__item.Schedules.Contains(this))
         {
             __item.RemoveSchedules(this);
         }
     }
 }
Esempio n. 2
0
 public virtual void AddRoutes(ItineraryRoute __item)
 {
     if (__item != null && routes != null && !routes.Contains(__item))
     {
         routes.Add(__item);
         if (!__item.Schedules.Contains(this))
         {
             __item.AddSchedules(this);
         }
     }
 }
Esempio n. 3
0
 public virtual void SetRoutesAt(ItineraryRoute __item, int __index)
 {
     if (__item == null)
     {
         routes[__index].RemoveSchedules(this);
     }
     else
     {
         routes[__index] = __item;
         if (!__item.Schedules.Contains(this))
         {
             __item.AddSchedules(this);
         }
     }
 }
Esempio n. 4
0
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(ItineraryRoute compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
Esempio n. 5
0
/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [ItineraryRoute] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ItineraryRoute Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ItineraryRoute copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ItineraryRoute)copiedObjects[this]);
            }
            copy = copy ?? new ItineraryRoute();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Duration              = this.Duration;
            copy.ETicketability        = this.ETicketability;
            copy.Remarks               = this.Remarks;
            copy.Active                = this.Active;
            copy.OnTimePercentage      = this.OnTimePercentage;
            copy.UpdatedAt             = this.UpdatedAt;
            copy.CO2Emissions          = this.CO2Emissions;
            copy.LuggageAvailability   = this.LuggageAvailability;
            copy.LuggageDimensions     = this.LuggageDimensions;
            copy.LuggageTermsOfService = this.LuggageTermsOfService;
            copy.PriceRangeMin         = this.PriceRangeMin;
            copy.PriceRangeMax         = this.PriceRangeMax;
            copy.ExternalIdentifier    = this.ExternalIdentifier;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.amenities = new List <Amenity>();
            if (deep && this.amenities != null)
            {
                foreach (var __item in this.amenities)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddAmenities(__item);
                        }
                        else
                        {
                            copy.AddAmenities(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddAmenities((Amenity)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.distance != null)
            {
                if (!copiedObjects.Contains(this.distance))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Distance = this.Distance;
                    }
                    else if (asNew)
                    {
                        copy.Distance = this.Distance.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.distance = this.distance.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Distance = (Distance)copiedObjects[this.Distance];
                    }
                    else
                    {
                        copy.distance = (Distance)copiedObjects[this.Distance];
                    }
                }
            }
            copy.schedules = new List <Schedule>();
            if (deep && this.schedules != null)
            {
                foreach (var __item in this.schedules)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddSchedules(__item);
                        }
                        else
                        {
                            copy.AddSchedules(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddSchedules((Schedule)copiedObjects[__item]);
                    }
                }
            }
            copy.waypoints = new List <GeoCoordinates>();
            if (deep && this.waypoints != null)
            {
                foreach (var __item in this.waypoints)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddWaypoints(__item);
                        }
                        else
                        {
                            copy.AddWaypoints(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddWaypoints((GeoCoordinates)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.datasource != null)
            {
                if (!copiedObjects.Contains(this.datasource))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Datasource = this.Datasource;
                    }
                    else if (asNew)
                    {
                        copy.Datasource = this.Datasource.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.datasource = this.datasource.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Datasource = (Datasource)copiedObjects[this.Datasource];
                    }
                    else
                    {
                        copy.datasource = (Datasource)copiedObjects[this.Datasource];
                    }
                }
            }
            return(copy);
        }