public virtual void RemoveTransportUnCaps(TransportUnCap __item)
 {
     if (__item != null)
     {
         InternalRemoveTransportUnCaps(__item);
     }
 }
 public virtual void AddTransportUnCaps(TransportUnCap __item)
 {
     if (__item == null)
     {
         return;
     }
     InternalAddTransportUnCaps(__item);
 }
 public virtual void AddAtIndexTransportUnCaps(int index, TransportUnCap __item)
 {
     if (__item == null)
     {
         return;
     }
     transportUnCaps?.Insert(index, __item);
 }
 public virtual void InternalRemoveTransportUnCaps(TransportUnCap __item)
 {
     if (__item == null)
     {
         return;
     }
     transportUnCaps?.Remove(__item);
 }
 public virtual void InternalAddTransportUnCaps(TransportUnCap __item)
 {
     if (__item == null || disableInternalAdditions)
     {
         return;
     }
     transportUnCaps?.Add(__item);
 }
 public virtual void SetTransportUnCapsAt(TransportUnCap __item, int __index)
 {
     if (__item == null)
     {
         transportUnCaps[__index] = null;
     }
     else
     {
         transportUnCaps[__index] = __item;
     }
 }
        public void Agreement_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _agreement_agreementstatuses_agreement = new DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus
            {
                IssuedBy           = "AgreementStatus_IssuedBy",
                Status             = "AgreementStatus_Status",
                DateIssued         = now,
                ApprovedBySonae    = true,
                ApprovedBySupplier = true,
                InProgress         = true,
                Active             = true,
                UnderRevision      = true,
            };
            var _agreement_agreementstatuses_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus
            {
                IssuedBy           = "AgreementStatus_IssuedBy",
                Status             = "AgreementStatus_Status",
                DateIssued         = now,
                ApprovedBySonae    = true,
                ApprovedBySupplier = true,
                InProgress         = true,
                Active             = true,
                UnderRevision      = true,
            };
            var _agreement_items_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Item
            {
                SKU              = "85c41988-a9ba-4eda-9414-d5e910f388a2Item_SKU",
                Description      = "Item_Description",
                UPC              = "Item_UPC",
                AvgDailyDemand   = 222222.22M,
                PalletSize       = 5412,
                SupplierPackSize = 2461,
                InnerPackSize    = 5128,
                PalletType       = "Item_PalletType",
                PalTI            = 965,
                PalHI            = 4274,
                UOM              = "Item_UOM",
            };
            var _agreement_items_agreements2 = new DSS1_RetailerDriverStockOptimisation.BO.Item
            {
                SKU              = "1111",
                Description      = "Item_Description",
                UPC              = "Item_UPC",
                AvgDailyDemand   = 222222.22M,
                PalletSize       = 2720,
                SupplierPackSize = 6994,
                InnerPackSize    = 6127,
                PalletType       = "Item_PalletType",
                PalTI            = 161,
                PalHI            = 6362,
                UOM              = "Item_UOM",
            };
            var _agreement_supplier_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Supplier
            {
                Code = "Supplier_Code",
                Name = "Supplier_Name",
            };
            var _agreement_warehouses_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Warehouse
            {
                Code        = "Warehouse_Code",
                Description = "Warehouse_Description",
                FlowType    = "Warehouse_FlowType",
            };
            var _agreement_warehouses_agreements2 = new DSS1_RetailerDriverStockOptimisation.BO.Warehouse
            {
                Code        = "Warehouse_Code",
                Description = "Warehouse_Description",
                FlowType    = "Warehouse_FlowType",
            };
            var _agreement_stockonhands_agreement = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand
            {
                Units = 3710,
                CurrentInventoryDays = 222222.22M,
                StockOnHandDate      = now,
                LeadTime             = "StockOnHand_LeadTime",
                TargetInventoryDays  = 222222.22M,
                FullTrackLoad        = true,
                WDDays = true,
            };
            var _agreement_stockonhands_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand
            {
                Units = 1751,
                CurrentInventoryDays = 222222.22M,
                StockOnHandDate      = now,
                LeadTime             = "StockOnHand_LeadTime",
                TargetInventoryDays  = 222222.22M,
                FullTrackLoad        = true,
                WDDays = true,
            };
            var _agreement_transportuncaps_agreement = new DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap
            {
                UOP        = "TransportUnCap_UOP",
                PercRound  = 2222222222.22222M,
                Tuc1       = 2222222222.22222M,
                SplitOcInd = "TransportUnCap_SplitOcInd",
                Status     = "TransportUnCap_Status",
            };
            var _agreement_transportuncaps_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap
            {
                UOP        = "TransportUnCap_UOP",
                PercRound  = 2222222222.22222M,
                Tuc1       = 2222222222.22222M,
                SplitOcInd = "TransportUnCap_SplitOcInd",
                Status     = "TransportUnCap_Status",
            };

            new PersistenceSpecification <DSS1_RetailerDriverStockOptimisation.BO.Agreement>(Session)
            .CheckProperty(p => p.FullTruckLoad, true)
            .CheckProperty(p => p.AgreementDocument, "Agreement_AgreementDocument")
            .CheckProperty(p => p.LeadTime, "Agreement_LeadTime")
            .CheckProperty(p => p.DateCreated, now)
            .CheckProperty(p => p.WDDeliveries, true)
            .CheckProperty(p => p.TargetInventoryDays, 6622)
            .CheckProperty(p => p.Profile, "Agreement_Profile")
            .CheckBag(p => p.AgreementStatuses, (new List <DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus>
            {
                _agreement_agreementstatuses_agreement,
                _agreement_agreementstatuses_agreement2
            }))
            .CheckBag(p => p.Items, (new List <DSS1_RetailerDriverStockOptimisation.BO.Item>
            {
                _agreement_items_agreements,
                _agreement_items_agreements2
            }))
            .CheckReference(p => p.Supplier, _agreement_supplier_agreements)
            .CheckBag(p => p.Warehouses, (new List <DSS1_RetailerDriverStockOptimisation.BO.Warehouse>
            {
                _agreement_warehouses_agreements,
                _agreement_warehouses_agreements2
            }))
            .CheckBag(p => p.StockOnHands, (new List <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand>
            {
                _agreement_stockonhands_agreement,
                _agreement_stockonhands_agreement2
            }))
            .CheckBag(p => p.TransportUnCaps, (new List <DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap>
            {
                _agreement_transportuncaps_agreement,
                _agreement_transportuncaps_agreement2
            }))
            .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(TransportUnCap 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 [TransportUnCap] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual TransportUnCap Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, TransportUnCap copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((TransportUnCap)copiedObjects[this]);
            }
            copy = copy ?? new TransportUnCap();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.UOP        = this.UOP;
            copy.PercRound  = this.PercRound;
            copy.Tuc1       = this.Tuc1;
            copy.SplitOcInd = this.SplitOcInd;
            copy.Status     = this.Status;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.warehouse != null)
            {
                if (!copiedObjects.Contains(this.warehouse))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Warehouse = this.Warehouse;
                    }
                    else if (asNew)
                    {
                        copy.Warehouse = this.Warehouse.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.warehouse = this.warehouse.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Warehouse = (Warehouse)copiedObjects[this.Warehouse];
                    }
                    else
                    {
                        copy.warehouse = (Warehouse)copiedObjects[this.Warehouse];
                    }
                }
            }
            return(copy);
        }