Ejemplo n.º 1
0
        /// <summary>
        /// Creates a copy of a volume discount
        /// </summary>
        /// <param name="volumeDiscountId">Id of the volume discount of which to create a copy</param>
        /// <param name="deepCopy">If <b>true</b> all child references are also copied</param>
        /// <returns>Copy of the given volume discount</returns>
        public static VolumeDiscount Copy(int volumeDiscountId, bool deepCopy)
        {
            //LOAD COPY (NO CACHE)
            VolumeDiscount source = new VolumeDiscount();

            if (source.Load(volumeDiscountId))
            {
                //IF DEEP COPY, RESET ALL CHILD REFERENCES
                if (deepCopy)
                {
                    foreach (VolumeDiscountLevel child in source.Levels)
                    {
                        child.VolumeDiscountLevelId = 0;
                        child.VolumeDiscountId      = 0;
                    }
                    foreach (VolumeDiscountGroup child in source.VolumeDiscountGroups)
                    {
                        child.VolumeDiscountId = 0;
                    }
                    foreach (CategoryVolumeDiscount child in source.CategoryVolumeDiscounts)
                    {
                        child.VolumeDiscountId = 0;
                    }
                    foreach (ProductVolumeDiscount child in source.ProductVolumeDiscounts)
                    {
                        child.VolumeDiscountId = 0;
                    }
                }
                source.VolumeDiscountId = 0;
                source.Save();
                return(source);
            }
            return(null);
        }
 public static SaveResult Update(VolumeDiscount volumeDiscount)
 {
     return(volumeDiscount.Save());
 }
 public static SaveResult Insert(VolumeDiscount volumeDiscount)
 {
     return(volumeDiscount.Save());
 }