Esempio n. 1
0
 public virtual void InternalRemoveVisibleTo(LSP __item)
 {
     if (__item == null)
     {
         return;
     }
     visibleTo?.Remove(__item);
 }
Esempio n. 2
0
 public virtual void InternalAddVisibleTo(LSP __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     visibleTo?.Add(__item);
 }
Esempio n. 3
0
 public virtual void RemoveVisibleTo(LSP __item)
 {
     if (__item != null)
     {
         if (visibleTo.Contains(__item))
         {
             InternalRemoveVisibleTo(__item);
         }
         if (__item.PrivateTemplates.Contains(this))
         {
             __item.RemovePrivateTemplates(this);
         }
     }
 }
Esempio n. 4
0
 public virtual void SetVisibleToAt(LSP __item, int __index)
 {
     if (__item == null)
     {
         visibleTo[__index].RemovePrivateTemplates(this);
     }
     else
     {
         visibleTo[__index] = __item;
         if (!__item.PrivateTemplates.Contains(this))
         {
             __item.AddPrivateTemplates(this);
         }
     }
 }
Esempio n. 5
0
 public virtual void AddAtIndexVisibleTo(int index, LSP __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!visibleTo.Contains(__item))
     {
         visibleTo.Insert(index, __item);
     }
     if (!__item.PrivateTemplates.Contains(this))
     {
         __item.AddPrivateTemplates(this);
     }
 }
Esempio n. 6
0
 public virtual void AddVisibleTo(LSP __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!visibleTo.Contains(__item))
     {
         InternalAddVisibleTo(__item);
     }
     if (!__item.PrivateTemplates.Contains(this))
     {
         __item.AddPrivateTemplates(this);
     }
 }
        public void ScheduledRouteTemplate_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _scheduledroutes_owner_scheduledroutetemplates = new DSS3_LogisticsPoolingForUrbanDistribution.BO.RegionalAgent
            {
                AgencyCode        = "RegionalAgent_AgencyCode",
                AgencyDescription = "RegionalAgent_AgencyDescription",
                AgencyAddress     = "RegionalAgent_AgencyAddress",
                IsSelected        = true,
                Rating            = 680,
            };
            var _scheduledroutes_visibleto_privatetemplates = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LSP
            {
                LSPName        = "LSP_LSPName",
                LSPDescription = "LSP_LSPDescription",
            };
            var _scheduledroutes_visibleto_privatetemplates2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LSP
            {
                LSPName        = "LSP_LSPName",
                LSPDescription = "LSP_LSPDescription",
            };
            var _scheduledroutes_ownerlsp_scheduledroutetemplate = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LSP
            {
                LSPName        = "LSP_LSPName",
                LSPDescription = "LSP_LSPDescription",
            };
            var _scheduledroutes_visibletoras_scheduledroutetemplate = new DSS3_LogisticsPoolingForUrbanDistribution.BO.RegionalAgent
            {
                AgencyCode        = "RegionalAgent_AgencyCode",
                AgencyDescription = "RegionalAgent_AgencyDescription",
                AgencyAddress     = "RegionalAgent_AgencyAddress",
                IsSelected        = true,
                Rating            = 5290,
            };
            var _scheduledroutes_visibletoras_scheduledroutetemplate2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.RegionalAgent
            {
                AgencyCode        = "RegionalAgent_AgencyCode",
                AgencyDescription = "RegionalAgent_AgencyDescription",
                AgencyAddress     = "RegionalAgent_AgencyAddress",
                IsSelected        = true,
                Rating            = 8490,
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.ScheduledRouteTemplate>(Session)
            .CheckProperty(p => p.Origin, "ScheduledRouteTemplate_Origin")
            .CheckProperty(p => p.Destination, "ScheduledRouteTemplate_Destination")
            .CheckProperty(p => p.DaysOfWeek, "ScheduledRouteTemplate_DaysOfWeek")
            .CheckProperty(p => p.PricePerPallet, 222222.22M)
            .CheckProperty(p => p.PricePerKilogram, 222222.22M)
            .CheckProperty(p => p.PricePerCubicMeter, 222222.22M)
            .CheckProperty(p => p.TotalAvailableCapacityKG, 222222.22M)
            .CheckProperty(p => p.EffectiveFrom, now)
            .CheckProperty(p => p.EffectiveTo, now)
            .CheckProperty(p => p.AvailableCapacityLaden, 9757)
            .CheckProperty(p => p.CreatedOn, now)
            .CheckProperty(p => p.IsPrivate, true)
            .CheckProperty(p => p.TotalAvailableCapacityLaden, 6829)
            .CheckProperty(p => p.TotalAvailableCapacityM3, 222222.22M)
            .CheckProperty(p => p.AvailableCapacityKG, 222222.22M)
            .CheckProperty(p => p.AvailableCapacityM3, 222222.22M)
            .CheckProperty(p => p.FixedPrice, 222222.22M)
            .CheckProperty(p => p.TruckPlate, "ScheduledRouteTemplate_TruckPlate")
            .CheckProperty(p => p.DeliveryDate, now)
            .CheckProperty(p => p.ByRA, true)
            .CheckReference(p => p.Owner, _scheduledroutes_owner_scheduledroutetemplates)
            .CheckBag(p => p.VisibleTo, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.LSP>
            {
                _scheduledroutes_visibleto_privatetemplates,
                _scheduledroutes_visibleto_privatetemplates2
            }))
            .CheckReference(p => p.OwnerLSP, _scheduledroutes_ownerlsp_scheduledroutetemplate)
            .CheckBag(p => p.VisibleToRAs, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.RegionalAgent>
            {
                _scheduledroutes_visibletoras_scheduledroutetemplate,
                _scheduledroutes_visibletoras_scheduledroutetemplate2
            }))
            .VerifyTheMappings();
        }
        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();
        }
Esempio n. 9
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(LSP compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
Esempio n. 10
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 [LSP] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual LSP Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, LSP copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((LSP)copiedObjects[this]);
            }
            copy = copy ?? new LSP();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.LSPName        = this.LSPName;
            copy.LSPDescription = this.LSPDescription;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.lSPUsers = new List <LSPUser>();
            if (deep && this.lSPUsers != null)
            {
                foreach (var __item in this.lSPUsers)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddLSPUsers(__item);
                        }
                        else
                        {
                            copy.AddLSPUsers(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddLSPUsers((LSPUser)copiedObjects[__item]);
                    }
                }
            }
            copy.privateTemplates = new List <ScheduledRouteTemplate>();
            if (deep && this.privateTemplates != null)
            {
                foreach (var __item in this.privateTemplates)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPrivateTemplates(__item);
                        }
                        else
                        {
                            copy.AddPrivateTemplates(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPrivateTemplates((ScheduledRouteTemplate)copiedObjects[__item]);
                    }
                }
            }
            copy.workContracts = new List <WorkContract>();
            if (deep && this.workContracts != null)
            {
                foreach (var __item in this.workContracts)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddWorkContracts(__item);
                        }
                        else
                        {
                            copy.AddWorkContracts(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddWorkContracts((WorkContract)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }