public virtual void SetWarehousesSupportAt(Warehouse __item, int __index)
 {
     if (__item == null)
     {
         warehousesSupport[__index].RemoveRegionalAgentsService(this);
     }
     else
     {
         warehousesSupport[__index] = __item;
         if (!__item.RegionalAgentsService.Contains(this))
         {
             __item.AddRegionalAgentsService(this);
         }
     }
 }
 public virtual void AddWarehousesSupport(Warehouse __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!warehousesSupport.Contains(__item))
     {
         InternalAddWarehousesSupport(__item);
     }
     if (!__item.RegionalAgentsService.Contains(this))
     {
         __item.AddRegionalAgentsService(this);
     }
 }
 public virtual void AddAtIndexWarehousesSupport(int index, Warehouse __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!warehousesSupport.Contains(__item))
     {
         warehousesSupport.Insert(index, __item);
     }
     if (!__item.RegionalAgentsService.Contains(this))
     {
         __item.AddRegionalAgentsService(this);
     }
 }
예제 #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 [Warehouse] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual Warehouse Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, Warehouse copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((Warehouse)copiedObjects[this]);
            }
            copy = copy ?? new Warehouse();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Description = this.Description;
            copy.Title       = this.Title;
            copy.Address     = this.Address;
            copy.Telephone   = this.Telephone;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.geoCoordinates != null)
            {
                if (!copiedObjects.Contains(this.geoCoordinates))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.GeoCoordinates = this.GeoCoordinates;
                    }
                    else if (asNew)
                    {
                        copy.GeoCoordinates = this.GeoCoordinates.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.geoCoordinates = this.geoCoordinates.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.GeoCoordinates = (GeoCoordinates)copiedObjects[this.GeoCoordinates];
                    }
                    else
                    {
                        copy.geoCoordinates = (GeoCoordinates)copiedObjects[this.GeoCoordinates];
                    }
                }
            }
            copy.regionalAgentsService = new List <RegionalAgent>();
            if (deep && this.regionalAgentsService != null)
            {
                foreach (var __item in this.regionalAgentsService)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddRegionalAgentsService(__item);
                        }
                        else
                        {
                            copy.AddRegionalAgentsService(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddRegionalAgentsService((RegionalAgent)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }