public virtual void SetShippingOrdersAt(ShippingOrder __item, int __index)
 {
     if (__item == null)
     {
         shippingOrders[__index].RemoveShipment(this);
     }
     else
     {
         shippingOrders[__index] = __item;
         if (!__item.Shipment.Contains(this))
         {
             __item.AddShipment(this);
         }
     }
 }
 public virtual void AddShippingOrders(ShippingOrder __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!shippingOrders.Contains(__item))
     {
         InternalAddShippingOrders(__item);
     }
     if (!__item.Shipment.Contains(this))
     {
         __item.AddShipment(this);
     }
 }
 public virtual void AddAtIndexShippingOrders(int index, ShippingOrder __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!shippingOrders.Contains(__item))
     {
         shippingOrders.Insert(index, __item);
     }
     if (!__item.Shipment.Contains(this))
     {
         __item.AddShipment(this);
     }
 }
Esempio n. 4
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 [ShippingOrder] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ShippingOrder Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ShippingOrder copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ShippingOrder)copiedObjects[this]);
            }
            copy = copy ?? new ShippingOrder();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.DepartureDate   = this.DepartureDate;
            copy.ArrivalDate     = this.ArrivalDate;
            copy.Shipper         = this.Shipper;
            copy.Carrier         = this.Carrier;
            copy.CurrentStatus   = this.CurrentStatus;
            copy.ItemDescription = this.ItemDescription;
            copy.Conditions      = this.Conditions;
            copy.AggregateVolume = this.AggregateVolume;
            copy.Priority        = this.Priority;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.shipment = new List <Shipment>();
            if (deep && this.shipment != null)
            {
                foreach (var __item in this.shipment)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddShipment(__item);
                        }
                        else
                        {
                            copy.AddShipment(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddShipment((Shipment)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.departurePoint != null)
            {
                if (!copiedObjects.Contains(this.departurePoint))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.DeparturePoint = this.DeparturePoint;
                    }
                    else if (asNew)
                    {
                        copy.DeparturePoint = this.DeparturePoint.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.departurePoint = this.departurePoint.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.DeparturePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                    else
                    {
                        copy.departurePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                }
            }
            if (deep && this.arrivalPoint != null)
            {
                if (!copiedObjects.Contains(this.arrivalPoint))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.ArrivalPoint = this.ArrivalPoint;
                    }
                    else if (asNew)
                    {
                        copy.ArrivalPoint = this.ArrivalPoint.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.arrivalPoint = this.arrivalPoint.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.ArrivalPoint = (Location)copiedObjects[this.ArrivalPoint];
                    }
                    else
                    {
                        copy.arrivalPoint = (Location)copiedObjects[this.ArrivalPoint];
                    }
                }
            }
            copy.statusEvolution = new List <StatusEvolution>();
            if (deep && this.statusEvolution != null)
            {
                foreach (var __item in this.statusEvolution)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddStatusEvolution(__item);
                        }
                        else
                        {
                            copy.AddStatusEvolution(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddStatusEvolution((StatusEvolution)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.parent != null)
            {
                if (!copiedObjects.Contains(this.parent))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Parent = this.Parent;
                    }
                    else if (asNew)
                    {
                        copy.Parent = this.Parent.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.parent = this.parent.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Parent = (ShippingOrder)copiedObjects[this.Parent];
                    }
                    else
                    {
                        copy.parent = (ShippingOrder)copiedObjects[this.Parent];
                    }
                }
            }
            copy.plannedVolume = new List <CustomVolume>();
            if (deep && this.plannedVolume != null)
            {
                foreach (var __item in this.plannedVolume)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPlannedVolume(__item);
                        }
                        else
                        {
                            copy.AddPlannedVolume(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPlannedVolume((CustomVolume)copiedObjects[__item]);
                    }
                }
            }
            copy.actualVolume = new List <CustomVolume>();
            if (deep && this.actualVolume != null)
            {
                foreach (var __item in this.actualVolume)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddActualVolume(__item);
                        }
                        else
                        {
                            copy.AddActualVolume(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddActualVolume((CustomVolume)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.itemType != null)
            {
                if (!copiedObjects.Contains(this.itemType))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.ItemType = this.ItemType;
                    }
                    else if (asNew)
                    {
                        copy.ItemType = this.ItemType.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.itemType = this.itemType.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.ItemType = (ItemType)copiedObjects[this.ItemType];
                    }
                    else
                    {
                        copy.itemType = (ItemType)copiedObjects[this.ItemType];
                    }
                }
            }
            return(copy);
        }