예제 #1
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(OwnershipCost compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }
        public void Vehicule_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _vehiculebo_distancecosts_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.DistanceCosts
            {
                TotalDistanceDriven  = 222222.22M,
                TotalDistanceService = 222222.22M,
                OilCost              = 222222.22M,
                OilConsumption       = 222222.22M,
                TireCost             = 222222.22M,
                YearlyReparationCost = 222222.22M,
                Cost            = 222222.22M,
                TireConsumption = 222222.22M,
            };
            var _vehiculebo_timecosts_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.TimeCosts
            {
                DriverSalary               = 222222.22M,
                DriverWorkHours            = 222222.22M,
                DriverServiceHours         = 222222.22M,
                VehiculeHoursPerDay        = 222222.22M,
                VehiculeDaysPerYear        = 222222.22M,
                RoadTax                    = 222222.22M,
                VehiculeInsurance          = 222222.22M,
                GoodsInssurance            = 222222.22M,
                Maintainance               = 222222.22M,
                DaysOfReplacementVehicules = 222222.22M,
                CostOfReplacement          = 222222.22M,
                Cost = 222222.22M,
            };
            var _vehiculebo_ownershipcost_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.OwnershipCost
            {
                VehiculePurchaseCost     = 222222.22M,
                RefrigerationSystemCost  = 222222.22M,
                LetteringCost            = 222222.22M,
                InterestRate             = 222222.22M,
                PaybackPeriod            = 222222.22M,
                TotalDistancePerVehicule = 222222.22M,
                AmortizationPeriod       = 222222.22M,
                ResidualValue            = 222222.22M,
                UtilizationPeriod        = 222222.22M,
                Cost = 222222.22M,
            };
            var _vehiculebo_amortizationtype1_vehicule = new DSS3_LogisticsPoolingForUrbanDistribution.BO.AmortizationType
            {
                Label = "AmortizationType_Label",
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.Vehicule>(Session)
            .CheckProperty(p => p.OverHeadCost, 222222.22M)
            .CheckProperty(p => p.CalculatedTimeCost, 222222.22M)
            .CheckProperty(p => p.CalculatedDistanceCost, 222222.22M)
            .CheckProperty(p => p.CalculatedOwnershipCost, 222222.22M)
            .CheckProperty(p => p.VehiculeType, "Vehicule_VehiculeType")
            .CheckProperty(p => p.Volume, "Vehicule_Volume")
            .CheckProperty(p => p.CO2perKm, 222222.22M)
            .CheckProperty(p => p.AmortizationType, "Vehicule_AmortizationType")
            .CheckProperty(p => p.MaximumLoad, 222222.22M)
            .CheckReference(p => p.DistanceCosts, _vehiculebo_distancecosts_vehicule)
            .CheckReference(p => p.TimeCosts, _vehiculebo_timecosts_vehicule)
            .CheckReference(p => p.OwnershipCost, _vehiculebo_ownershipcost_vehicule)
            .CheckReference(p => p.AmortizationType1, _vehiculebo_amortizationtype1_vehicule)
            .VerifyTheMappings();
        }
예제 #3
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 [OwnershipCost] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual OwnershipCost Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, OwnershipCost copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((OwnershipCost)copiedObjects[this]);
            }
            copy = copy ?? new OwnershipCost();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.VehiculePurchaseCost     = this.VehiculePurchaseCost;
            copy.RefrigerationSystemCost  = this.RefrigerationSystemCost;
            copy.LetteringCost            = this.LetteringCost;
            copy.InterestRate             = this.InterestRate;
            copy.PaybackPeriod            = this.PaybackPeriod;
            copy.TotalDistancePerVehicule = this.TotalDistancePerVehicule;
            copy.AmortizationPeriod       = this.AmortizationPeriod;
            copy.ResidualValue            = this.ResidualValue;
            copy.UtilizationPeriod        = this.UtilizationPeriod;
            copy.Cost = this.Cost;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.vehicule != null)
            {
                if (!copiedObjects.Contains(this.vehicule))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Vehicule = this.Vehicule;
                    }
                    else if (asNew)
                    {
                        copy.Vehicule = this.Vehicule.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.vehicule = this.vehicule.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Vehicule = (Vehicule)copiedObjects[this.Vehicule];
                    }
                    else
                    {
                        copy.vehicule = (Vehicule)copiedObjects[this.Vehicule];
                    }
                }
            }
            return(copy);
        }