Ejemplo n.º 1
0
        public static RetailPromo GetRetailPromo(Product product)
        {
            try
            {
                using (SqlConnection connection = Exigo.Sql())
                {
                    string SqlProcedure   = string.Format("[dbo].[RetailDiscount] '{0}'", product.ItemCode);
                    var    retailDiscount = connection.Query <RetailPromo>(SqlProcedure).FirstOrDefault();
                    if (retailDiscount == null)
                    {
                        return(null);
                    }

                    var discount = new RetailPromo();

                    discount.ItemCode       = retailDiscount.ItemCode;
                    discount.DiscountType   = retailDiscount.DiscountType;
                    discount.DiscountAmount = retailDiscount.DiscountAmount;
                    discount.BV             = retailDiscount.BV;
                    discount.CV             = retailDiscount.CV;


                    return(discount);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add Discount for Eligible Product
        /// </summary>
        /// <param name="promo"></param>
        /// <param name="product"></param>
        private static void AddEligibleDiscounts(Common.Services.RetailPromo promo, Product product)
        {
            product.EligibleDiscounts.Add(new DiscountFactory().CreateDiscount(
                                              (DiscountType)promo.DiscountType,
                                              (decimal)promo.DiscountAmount,
                                              promo.BV,
                                              promo.CV));

            var productDiscount = product.EligibleDiscounts.Find(d => d.DiscountType == (DiscountType)promo.DiscountType);

            product.ApplyDiscount(productDiscount);
            product.ApplyDiscountType = productDiscount.DiscountType;
            product.PriceEachOverride = product.DiscountedPrice;
            product.AppliedAmount     = productDiscount.AppliedAmount;
        }