Exemple #1
0
        /// <summary>
        /// Creates a clone of this Coupon object
        /// </summary>
        /// <param name="deepClone">If <b>true</b> all the child elements are also copied. (TODO)</param>
        /// <returns>A clone of this coupon object</returns>
        public Coupon Clone(bool deepClone)
        {
            Coupon cloneItem = new Coupon();

            cloneItem.CouponTypeId       = this.CouponTypeId;
            cloneItem.Name               = this.Name;
            cloneItem.CouponCode         = this.CouponCode;
            cloneItem.DiscountAmount     = this.DiscountAmount;
            cloneItem.IsPercent          = this.IsPercent;
            cloneItem.MaxValue           = this.MaxValue;
            cloneItem.MinPurchase        = this.MinPurchase;
            cloneItem.MinQuantity        = this.MinQuantity;
            cloneItem.MaxQuantity        = this.MaxQuantity;
            cloneItem.QuantityInterval   = this.QuantityInterval;
            cloneItem.MaxUses            = this.MaxUses;
            cloneItem.MaxUsesPerCustomer = this.MaxUsesPerCustomer;
            cloneItem.StartDate          = this.StartDate;
            cloneItem.EndDate            = this.EndDate;
            cloneItem.ProductRule        = this.ProductRule;
            cloneItem.AllowCombine       = this.AllowCombine;
            if (deepClone)
            {
                // COPY CHILD OBJECTS
                // WE HAVE TO SAVE THE COUPON
                if (cloneItem.Save() != SaveResult.Failed)
                {
                    // COPY GROUPS
                    foreach (CouponGroup grop in this.CouponGroups)
                    {
                        cloneItem.CouponGroups.Add(new CouponGroup(cloneItem.CouponId, grop.GroupId));
                    }
                    cloneItem.CouponGroups.Save();

                    // COPY PRODUCTS
                    foreach (CouponProduct product in this.CouponProducts)
                    {
                        cloneItem.CouponProducts.Add(new CouponProduct(cloneItem.CouponId, product.ProductId));
                    }
                    cloneItem.CouponProducts.Save();

                    // COPY SHIP METHODS
                    foreach (CouponShipMethod couponShipMethod in this.CouponShipMethods)
                    {
                        cloneItem.CouponShipMethods.Add(new CouponShipMethod(cloneItem.CouponId, couponShipMethod.ShipMethodId));
                    }
                    cloneItem.CouponShipMethods.Save();
                }
            }
            return(cloneItem);
        }
Exemple #2
0
 public static SaveResult Update(Coupon coupon)
 {
     return(coupon.Save());
 }
Exemple #3
0
 public static SaveResult Insert(Coupon coupon)
 {
     return(coupon.Save());
 }