コード例 #1
0
 /// <summary>
 /// Adds newgistics style parcel to the Shipment.
 /// </summary>
 /// <returns>The parcel.</returns>
 /// <param name="f">Fluent object.</param>
 /// <param name="p">Parcel to add</param>
 /// <typeparam name="T">IShipment concrete type.</typeparam>
 /// <typeparam name="O">IShipmentOptions concrete type.</typeparam>
 public static ShipmentFluent <T> NewgisticsParcel <T, O>(
     this ShipmentFluent <T> f,
     IParcel p
     ) where T : class, IShipment, new()
     where O : class, IShipmentOptions, new()
 {
     f.Parcel(p);
     if (p.Dimension.IrregularParcelGirth > 0)
     {
         T shipment = f;
         foreach (var o in shipment.ShipmentOptions)
         {
             if (o.ShipmentOption == ShipmentOption.IS_RECTANGULAR)
             {
                 o.Value = "false";
                 return(f);
             }
         }
         var rectOpt = new O
         {
             ShipmentOption = ShipmentOption.IS_RECTANGULAR,
             Value          = "false"
         };
     }
     return(f);
 }
        /// <summary>
        /// Factory method to create a ShipmentFluent. Use instead of new(). Use at the start of the fluent method chain.
        /// </summary>
        /// <returns></returns>
        public static ShipmentFluent <T> Create()
        {
            var a = new ShipmentFluent <T>()
            {
                _shipment = new T()
            };

            return(a);
        }
        /// <summary>
        /// Returns the shipment.
        /// </summary>
        /// <returns>The shipment.</returns>
        /// <param name="f">this</param>
        /// <typeparam name="T">Type of the IShipment</typeparam>
        public static ShipmentFluent <T> ReturnShipment <T>(this ShipmentFluent <T> f) where T : class, IShipment, new()
        {
            T shipment = ((T)f);

            if (shipment.ShipmentOptions != null)
            {
                foreach (var o in shipment.ShipmentOptions)
                {
                    if (o.ShipmentOption == ShipmentOption.ADD_TO_MANIFEST)
                    {
                        o.Value = "false";
                    }
                }
            }
            return(f.ShipmentType(ShipmentType.RETURN).ShipperRatePlan(null));
        }
コード例 #4
0
        /// <summary>
        /// Reference the specified f, referenceNumber, addlRef1 and addlRef2.
        /// </summary>
        /// <returns>The reference.</returns>
        /// <param name="f">The object</param>
        /// <param name="referenceNumber">Reference number.</param>
        /// <param name="addlRef1">Addl ref1.</param>
        /// <param name="addlRef2">Addl ref2.</param>
        /// <typeparam name="T">IShipment concrete class.</typeparam>
        /// <typeparam name="R">IReference concrete class.</typeparam>
        public static ShipmentFluent <T> Reference <T, R>(
            this ShipmentFluent <T> f,
            string referenceNumber,
            string addlRef1 = null,
            string addlRef2 = null
            ) where T : class, IShipment, new()
            where R : class, IReference, new()
        {
            T   shipment = ((T)f);
            var refs     = new List <R>();

            shipment.References = refs;
            var refNumber = new R
            {
                Name  = "ReferenceNumber",
                Value = referenceNumber
            };

            refs.Add(refNumber);
            if (addlRef1 != null)
            {
                var refAddlRef1 = new R
                {
                    Name  = "AddlRef1",
                    Value = addlRef1
                };
                refs.Add(refAddlRef1);
            }
            if (addlRef2 != null)
            {
                var refAddlRef2 = new R
                {
                    Name  = "AddlRef2",
                    Value = addlRef2
                };
                refs.Add(refAddlRef2);
            }
            return(f);
        }