Example #1
0
 public virtual void RemoveScheduledRoutes(ScheduledRoute __item)
 {
     if (__item != null)
     {
         __item.WorkContract = null;
     }
 }
Example #2
0
 public virtual void InternalRemoveScheduledRoutes(ScheduledRoute __item)
 {
     if (__item == null)
     {
         return;
     }
     scheduledRoutes?.Remove(__item);
 }
Example #3
0
 public virtual void InternalAddScheduledRoutes(ScheduledRoute __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     scheduledRoutes?.Add(__item);
 }
Example #4
0
 public virtual void AddScheduledRoutes(ScheduledRoute __item)
 {
     if (__item == null)
     {
         return;
     }
     if (__item.WorkContract != this)
     {
         __item.WorkContract = this;
     }
 }
Example #5
0
 public virtual void SetScheduledRoutesAt(ScheduledRoute __item, int __index)
 {
     if (__item == null)
     {
         scheduledRoutes[__index].WorkContract = null;
     }
     else
     {
         scheduledRoutes[__index] = __item;
         if (__item.WorkContract != this)
         {
             __item.WorkContract = this;
         }
     }
 }
Example #6
0
 public virtual void AddAtIndexScheduledRoutes(int index, ScheduledRoute __item)
 {
     if (__item == null)
     {
         return;
     }
     scheduledRoutes?.Insert(index, __item);
     disableInternalAdditions = true;
     try
     {
         if (__item.WorkContract != this)
         {
             __item.WorkContract = this;
         }
     }
     finally
     {
         disableInternalAdditions = false;
     }
 }
        public void WorkContract_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _workcontract_regionalagent_workcontract = new DSS3_LogisticsPoolingForUrbanDistribution.BO.RegionalAgent
            {
                AgencyCode        = "RegionalAgent_AgencyCode",
                AgencyDescription = "RegionalAgent_AgencyDescription",
                AgencyAddress     = "RegionalAgent_AgencyAddress",
                IsSelected        = true,
                Rating            = 7607,
            };
            var _workcontract_scheduledroutes_workcontract = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ScheduledRoute
            {
                Origin                   = "ScheduledRoute_Origin",
                Destination              = "ScheduledRoute_Destination",
                DaysOfWeek               = "ScheduledRoute_DaysOfWeek",
                PricePerPallet           = 222222.22M,
                PricePerKilogram         = 222222.22M,
                PricePerCubicMeter       = 222222.22M,
                TotalAvailableCapacityKG = 222222.22M,
                EffectiveFrom            = now,
                EffectiveTo              = now,
                Revision                 = 248,
                GUID = "ScheduledRoute_GUID",
                ReservedCapacityLaden = 6260,
                BaseId = 440,
                TotalAvailableCapacityM3    = 222222.22M,
                TotalAvailableCapacityLaden = 1650,
                ReservedCapacityKG          = 222222.22M,
                ReservedCapacityM3          = 222222.22M,
                FixedPrice          = 222222.22M,
                OriginComments      = "ScheduledRoute_OriginComments",
                DestinationComments = "ScheduledRoute_DestinationComments",
                TruckPlate          = "ScheduledRoute_TruckPlate",
                DeliveryDate        = now,
            };
            var _workcontract_scheduledroutes_workcontract2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ScheduledRoute
            {
                Origin                   = "ScheduledRoute_Origin",
                Destination              = "ScheduledRoute_Destination",
                DaysOfWeek               = "ScheduledRoute_DaysOfWeek",
                PricePerPallet           = 222222.22M,
                PricePerKilogram         = 222222.22M,
                PricePerCubicMeter       = 222222.22M,
                TotalAvailableCapacityKG = 222222.22M,
                EffectiveFrom            = now,
                EffectiveTo              = now,
                Revision                 = 2434,
                GUID = "ScheduledRoute_GUID",
                ReservedCapacityLaden = 710,
                BaseId = 4463,
                TotalAvailableCapacityM3    = 222222.22M,
                TotalAvailableCapacityLaden = 3119,
                ReservedCapacityKG          = 222222.22M,
                ReservedCapacityM3          = 222222.22M,
                FixedPrice          = 222222.22M,
                OriginComments      = "ScheduledRoute_OriginComments",
                DestinationComments = "ScheduledRoute_DestinationComments",
                TruckPlate          = "ScheduledRoute_TruckPlate",
                DeliveryDate        = now,
            };
            var _workcontract_lsp_workcontracts = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LSP
            {
                LSPName        = "LSP_LSPName",
                LSPDescription = "LSP_LSPDescription",
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.WorkContract>(Session)
            .CheckProperty(p => p.CreationDate, now)
            .CheckProperty(p => p.LastUpdate, now)
            .CheckReference(p => p.RegionalAgent, _workcontract_regionalagent_workcontract)
            .CheckBag(p => p.ScheduledRoutes, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.ScheduledRoute>
            {
                _workcontract_scheduledroutes_workcontract,
                _workcontract_scheduledroutes_workcontract2
            }))
            .CheckReference(p => p.LSP, _workcontract_lsp_workcontracts)
            .VerifyTheMappings();
        }
/// <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(ScheduledRoute compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
/// <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 [ScheduledRoute] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ScheduledRoute Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ScheduledRoute copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ScheduledRoute)copiedObjects[this]);
            }
            copy = copy ?? new ScheduledRoute();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Origin                   = this.Origin;
            copy.Destination              = this.Destination;
            copy.DaysOfWeek               = this.DaysOfWeek;
            copy.PricePerPallet           = this.PricePerPallet;
            copy.PricePerKilogram         = this.PricePerKilogram;
            copy.PricePerCubicMeter       = this.PricePerCubicMeter;
            copy.TotalAvailableCapacityKG = this.TotalAvailableCapacityKG;
            copy.EffectiveFrom            = this.EffectiveFrom;
            copy.EffectiveTo              = this.EffectiveTo;
            copy.TypeOfGoods              = this.TypeOfGoods;
            copy.Revision                 = this.Revision;
            copy.GUID = this.GUID;
            copy.ReservedCapacityLaden = this.ReservedCapacityLaden;
            copy.State     = this.State;
            copy.BaseId    = this.BaseId;
            copy.Frequency = this.Frequency;
            copy.TotalAvailableCapacityM3    = this.TotalAvailableCapacityM3;
            copy.TotalAvailableCapacityLaden = this.TotalAvailableCapacityLaden;
            copy.ReservedCapacityKG          = this.ReservedCapacityKG;
            copy.ReservedCapacityM3          = this.ReservedCapacityM3;
            copy.FixedPrice          = this.FixedPrice;
            copy.OriginComments      = this.OriginComments;
            copy.DestinationComments = this.DestinationComments;
            copy.TruckPlate          = this.TruckPlate;
            copy.stringenum          = this.stringenum;
            copy.DeliveryDate        = this.DeliveryDate;
            copy.Attribute           = this.Attribute;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.workContract != null)
            {
                if (!copiedObjects.Contains(this.workContract))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.WorkContract = this.WorkContract;
                    }
                    else if (asNew)
                    {
                        copy.WorkContract = this.WorkContract.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.workContract = this.workContract.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.WorkContract = (WorkContract)copiedObjects[this.WorkContract];
                    }
                    else
                    {
                        copy.workContract = (WorkContract)copiedObjects[this.WorkContract];
                    }
                }
            }
            return(copy);
        }