public PromotionsViewModel(IPromotion promo)
 {
     this.id = promo.id;
     this.content = promo.content;
     this.specialization = promo.specialization;
     this.created_by = promo.created_by;
     this.updated_by = promo.updated_by;
     this.date_created = promo.date_created;
     this.date_updated = promo.date_updated;
     this.promotion_date = promo.promotion_date;
 }
 public PromotionViewModel(IPromotion promo)
 {
     this.id = promo.id;
     this.content = promo.content;
     this.specialization = promo.specialization;
     this.specDesc = promo.specDesc;
     this.created_by = promo.created_by;
     this.updated_by = promo.updated_by;
     this.date_created = promo.date_created;
     this.date_updated = promo.date_updated;
     this.promotion_date = promo.promotion_date;
     this.title = promo.title;
     this.meta_description = promo.meta_description;
     this.meta_tags = promo.meta_tags;
     this.teaser = promo.teaser;
 }
Пример #3
0
    public Promotion()
    {
        //初始化ASP.NET内置对象
        Response    = System.Web.HttpContext.Current.Response;
        Request     = System.Web.HttpContext.Current.Request;
        Server      = System.Web.HttpContext.Current.Server;
        Session     = System.Web.HttpContext.Current.Session;
        Application = System.Web.HttpContext.Current.Application;


        tools     = ToolsFactory.CreateTools();
        MyBLL     = PromotionFactory.CreatePromotion();
        pub       = new Public_Class();
        myproduct = new Product();
        MyLimits  = PromotionLimitFactory.CreatePromotionLimit();
    }
 public void ApplyPromotions(List <PromoDefinition> activePromotions, List <OrderDetail> productCart)
 {
     foreach (var promo in activePromotions)
     {
         IPromotion promotion = PromotionFactory.GetFactory(promo);
         // no need to apply further promotions if a promotion is already applied
         //if (!this.IsPromoApplied)
         //{
         this.DiscountedAmount += promotion.ApplyPromotion(productCart);
         // mark promotion applied
         if (!this.IsPromoApplied && this.DiscountedAmount > 0)
         {
             this.IsPromoApplied = true;
         }
         //}
     }
 }
Пример #5
0
        static void Main(string[] args)

        {
            IPromotion promotion = null;

            promotion = new Promotion1();

            PromotionResult promotionResult = new PromotionResult(promotion);

            promotionResult.Items.Add(new ItemA()

            {
                NoOfItems = 3,

                Cost = 50
            });

            promotionResult.Items.Add(new ItemB()

            {
                NoOfItems = 2,

                Cost = 30
            });

            promotionResult.Items.Add(new ItemC()

            {
                NoOfItems = 2,

                Cost = 20
            });

            promotionResult.Items.Add(new ItemD()

            {
                NoOfItems = 2,

                Cost = 15
            });

            Console.WriteLine(promotionResult.Calculate());

            Console.ReadLine();
        }
        public void TestMethod_ScenarioC()

        {
            //Arrange

            IPromotion promotion = null;

            promotion = new Promotion1();

            PromotionResult promotionResult = new PromotionResult(promotion);

            promotionResult.Items.Add(new ItemA()

            {
                NoOfItems = 5,

                Cost = 50
            });

            promotionResult.Items.Add(new ItemB()

            {
                NoOfItems = 5,

                Cost = 30
            });

            promotionResult.Items.Add(new ItemC()

            {
                NoOfItems = 1,

                Cost = 20
            });

            //Act

            var result = promotionResult.Calculate();

            //Assert

            Assert.AreEqual <double>(result, 370);
        }
        public IEnumerable <IPromotionValidationResult> ValidatePromotion(IPromotion promotion, IRuleContext ruleContext, bool allowsPromotions)       // i need to return a validation message
        {
            if (promotion == null)
            {
                throw new ArgumentNullException("promotion", "Promotions cannot be null when validating.");
            }

            if (ruleContext == null)
            {
                throw new ArgumentNullException("ruleContext", "A rules context must be specified when validating promotions.");
            }

            if (!promotion.Active)
            {
                return new[] { new SimplePromotionValidationResult(false, "Promotion.Reason.InactivePromotion") }
            }
            ;

            if (!allowsPromotions)
            {
                return new[] { new SimplePromotionValidationResult(false, "Promotion.Reason.CustomerLevelDoesNotAllow") }
            }
            ;

            if (ruleContext.FilterByStore)
            {
                if (!promotion.MappedStores.Any(ps => ps.StoreID == ruleContext.StoreId))
                {
                    return new[] { new SimplePromotionValidationResult(false, "Promotion.Reason.MultiStore.NoMatch") }
                }
                ;
            }

            if (promotion.PromotionRules == null || promotion.PromotionDiscounts.Count() == 0)
            {
                return(new[] { new SimplePromotionValidationResult(false, "Promotion.Reason.DoesNotExist") });
            }
            else
            {
                return(promotion.PromotionRules.Select(r => r.Validate(this, ruleContext)));
            }
        }
Пример #8
0
        public DiscountInfo MakePromotionType(DiscountInfo discountInfo, int PromType)
        {
            IPromotion MyProm = null;

            try
            {
                Type type = Type.GetType(ConvertToClass(PromType), true);
                MyProm = (IPromotion)Activator.CreateInstance(type);
                this.BindDb(MyProm);
                MyProm.PatientType = discountInfo.PatientType;
                MyProm.CardID      = discountInfo.AccountID;
                MyProm.CostType    = discountInfo.CostType;
                MyProm.PromType    = PromType;
                return(MyProm.Calculation(discountInfo));
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
                return(discountInfo);
            }
        }
Пример #9
0
        public decimal ApplyPromotion(List <IProduct> product)
        {
            try
            {
                _product       = Utility.GetProductA(product);
                _promotionType = new Promotion1();
                totalPrice    += _promotionType.CalculatePriceAfterPromotion(_product);

                _product       = Utility.GetProductB(product);
                _promotionType = new Promotion2();
                totalPrice    += _promotionType.CalculatePriceAfterPromotion(_product);

                _product       = Utility.GetProductCD(product);
                _promotionType = new Promotion3();
                totalPrice    += _promotionType.CalculatePriceAfterPromotion(_product);
            }
            catch (Exception ex)
            {
                throw new PromotionException("error:-", ex);
            }
            return(totalPrice);
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PatientType">病人类型(1.门诊,2.住院)</param>
        /// <param name="CostType">病人收费类型</param>
        /// <param name="CardID">病人会员帐户ID</param>
        /// <param name="Amount">消费总金额</param>
        /// <param name="Detail">优惠明细"项目明细ID|金额|优惠金额"</param>
        /// <returns></returns>
        public decimal MakePromotionType(int PatientType, int CostType, int CardID, decimal Amount, DataTable Detail, DataTable dtPromClass, int PromType, out DataTable outdtPromClass, out DataTable outDetail)
        {
            IPromotion MyProm = null;

            try
            {
                Type type = Type.GetType(ConvertToClass(PromType), true);
                MyProm = (IPromotion)Activator.CreateInstance(type);
                this.BindDb(MyProm);
                MyProm.PatientType = PatientType;
                MyProm.CardID      = CardID;
                MyProm.CostType    = CostType;
                MyProm.PromType    = PromType;
                return(MyProm.Calculation(Amount, dtPromClass, Detail, out outdtPromClass, out outDetail));
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
                outdtPromClass = null;
                outDetail      = null;
                return(-1M);
            }
        }
Пример #11
0
        public void AddPromotionToMovementSummary(
            IPromotion promotion, UnitMovementSummary summary
            )
        {
            summary.CanTraverseLand         |= promotion.PermitsLandTraversal;
            summary.CanTraverseShallowWater |= promotion.PermitsShallowWaterTraversal;
            summary.CanTraverseDeepWater    |= promotion.PermitsDeepWaterTraversal;

            summary.BonusMovement += promotion.BonusMovement;
            summary.BonusVision   += promotion.BonusVision;

            foreach (var terrain in promotion.TerrainsWithIgnoredCosts)
            {
                summary.TerrainsWithIgnoredCosts.Add(terrain);
            }

            foreach (var shape in promotion.ShapesWithIgnoredCosts)
            {
                summary.ShapesWithIgnoredCosts.Add(shape);
            }

            foreach (var vegetation in promotion.VegetationsWithIgnoredCosts)
            {
                summary.VegetationsWithIgnoredCosts.Add(vegetation);
            }


            foreach (var shapes in promotion.ShapesConsumingFullMovement)
            {
                summary.ShapesConsumingFullMovement.Add(shapes);
            }

            foreach (var vegetation in promotion.VegetationsConsumingFullMovement)
            {
                summary.VegetationConsumingFullMovement.Add(vegetation);
            }
        }
Пример #12
0
        public static IPromotion CrearConexionServicio3(Models.ConnectionType type, string connectionString)
        {
            IPromotion nuevoMotor = null;

            switch (type)
            {
            case Models.ConnectionType.NONE:
                break;

            case Models.ConnectionType.MSSQL:
                SqlConexion sql = SqlConexion.Conectar(connectionString);
                nuevoMotor = PromotionService.CrearInstanciaSQL(sql);
                break;

            case Models.ConnectionType.MYSQL:

                break;

            default:
                break;
            }

            return(nuevoMotor);
        }
		public GenericPromotion(IPromotion data) {
		}
 public void ApplyPromotion(IPromotion promotion)
 {
     this.promotion = promotion;
     promotion.ApplyPromotion(this);
 }
Пример #15
0
 public void AddPromotion(IPromotion promotion)
 {
     _promotions.Add(promotion);
 }
Пример #16
0
 public DiscountManager(int customer, int price, IPromotion promo)
 {
     this.customer = customer;
     this.price    = price;
     this.promo    = promo;
 }
Пример #17
0
 private IList <Product.IProduct> GetProductsLinkedWithThePromotion(IPromotion promotion)
 {
     return(myOrderDetails.Products.Where(product => promotion.PromotionLinkedWithPlan.Contains(product.ProductName)).ToList());
 }
 public GetThreePayTenTests()
 {
     sut = new GetThreePayTen();
 }
 public void SetPromotion(IPromotion promotion)
 {
     Promotion = promotion;
 }
Пример #20
0
 public bool CanChoosePromotion(IPromotion promotion)
 {
     return(GetAvailablePromotions().Contains(promotion));
 }
Пример #21
0
        public int DisplayTotalAmountwithProducts()
        {
            int       NoOfA  = 0;
            int       NoOfB  = 0;
            int       NoOfC  = 0;
            int       NoOfD  = 0;
            bool      promoA = false;
            bool      promoB = false;
            bool      promoC = false;
            bool      promoD = false;
            Product   prodA  = new ProductA("A");
            Product   prodB  = new ProductB("B");
            Product   prodC  = new ProductC("C");
            Product   prodD  = new ProductD("D");
            int       Total  = 0;
            Factory   factory;
            FactoryCD factoryCD;

            NoOfA = CartProducts.Where(n => n.ProductCode == "A").Count();
            NoOfB = CartProducts.Where(n => n.ProductCode == "B").Count();
            NoOfC = CartProducts.Where(n => n.ProductCode == "C").Count();
            NoOfD = CartProducts.Where(n => n.ProductCode == "D").Count();

            if (NoOfA > 2)
            {
                int promopairs  = 0;
                int remainitems = 0;
                remainitems = NoOfA % 3;
                promopairs  = NoOfA / 3;
                factory     = new FactoryA();
                _IPromo     = factory.CreatePromotion();
                Total       = Total + _IPromo.Calculate(NoOfA, promopairs, remainitems);
                promoA      = true;
            }
            else if (NoOfB > 1)
            {
                int promopairs  = 0;
                int remainitems = 0;
                remainitems = NoOfB % 2;
                promopairs  = NoOfB / 2;
                factory     = new FactoryB();
                _IPromo     = factory.CreatePromotion();
                Total       = Total + _IPromo.Calculate(NoOfB, promopairs, remainitems);
                promoB      = true;
            }
            else if (NoOfC > 0 && NoOfD > 0)
            {
                int promopairs   = 0;
                int remainitemsC = 0;
                int remainitemsD = 0;

                if (NoOfC == NoOfD)
                {
                    promopairs   = NoOfC;
                    remainitemsC = 0;
                    remainitemsD = 0;
                }
                else if (NoOfC > NoOfD)
                {
                    promopairs   = NoOfD;
                    remainitemsC = NoOfC - NoOfD;
                    remainitemsD = 0;
                }
                else
                {
                    promopairs   = NoOfC;
                    remainitemsC = 0;
                    remainitemsD = NoOfD - NoOfC;
                }
                factoryCD = new FactoryPromoCD();
                _IPromoCD = factoryCD.CreatePromotionCD();
                Total     = Total + _IPromoCD.Calculate(NoOfC, NoOfD, promopairs, remainitemsC, remainitemsD);
                promoC    = true;
                promoD    = true;
            }
            foreach (Product prod in CartProducts)
            {
                if (prod.GetType().Name == "ProductA" && promoA == false)
                {
                    Console.WriteLine("{0} * A {1}", NoOfA, (NoOfA * prodA.price));
                    promoA = true;
                    Total  = Total + (NoOfA * prodA.price);
                }
                else if (prod.GetType().Name == "ProductB" && promoB == false)
                {
                    Console.WriteLine("{0} * B {1}", NoOfB, (NoOfB * prodB.price));
                    promoB = true;
                    Total  = Total + (NoOfB * prodB.price);
                }
                else if (prod.GetType().Name == "ProductC" && promoC == false)
                {
                    Console.WriteLine("{0} * C {1}", NoOfC, (NoOfC * prodC.price));
                    promoC = true;
                    Total  = Total + (NoOfC * prodC.price);
                }
                else if (prod.GetType().Name == "ProductD" && promoD == false)
                {
                    Console.WriteLine("{0} * D {1}", NoOfD, (NoOfD * prodD.price));
                    promoD = true;
                    Total  = Total + (NoOfD * prodD.price);
                }
            }
            return(Total);
        }
Пример #22
0
 public void AddPromotion(IPromotion promotion)
 {
     promotions.Add(promotion);
     StatePromotionsHaveChanged();
 }
        static void Main(string[] args)
        {
            bool loopContinue = true;


            while (loopContinue)
            {
                Console.WriteLine("Commiting New Changes with push");
                Console.WriteLine("Please Enter Option No. 1)Product Price Calculation");
                int option = Convert.ToInt32(Console.ReadLine());
                List <SkuProduct> prodList = new List <SkuProduct>();
                SkuProduct        productA = new SkuProduct();
                SkuProduct        productB = new SkuProduct();
                SkuProductCombo   productCombo = new SkuProductCombo();
                int                         count, total, finalAmount = 0;
                List <int>                  finalPrice     = new List <int>();
                PromotionFactory            promofactory   = new PromotionFactory();
                PromotionCombinationFactory prmoCombFacory = new PromotionCombinationFactory();

                switch (option)
                {
                case 1:
                    Console.WriteLine("Enter no. of prod to buy for Product A");
                    count            = Convert.ToInt32(Console.ReadLine());
                    productA.SkuName = "A";
                    productA.count   = count;
                    prodList.Add(productA);
                    Console.WriteLine("Enter no. of prod to buy for Product B");
                    count            = Convert.ToInt32(Console.ReadLine());
                    productB.SkuName = "B";
                    productB.count   = count;
                    prodList.Add(productB);
                    Console.WriteLine("Enter no. of prod to buy for Product C");
                    count = Convert.ToInt32(Console.ReadLine());
                    productCombo.SkuName1 = "C";
                    productCombo.count1   = count;
                    Console.WriteLine("Enter no. of prod to buy for Product D");
                    count = Convert.ToInt32(Console.ReadLine());
                    productCombo.SkuName2 = "D";
                    productCombo.count2   = count;
                    foreach (SkuProduct prod in prodList)
                    {
                        IPromotion promo = promofactory.GetPromoOffer(prod.SkuName);
                        total = promo.CalculatePrice(prod.count);
                        finalPrice.Add(total);
                    }
                    IPromotionCombined promocomb = prmoCombFacory.GetPromoOffer(productCombo.SkuName1, productCombo.SkuName2);
                    total = promocomb.CalculatePrice(productCombo.count1, productCombo.count2);
                    finalPrice.Add(total);
                    foreach (int val in finalPrice)
                    {
                        finalAmount = finalAmount + val;
                    }
                    Console.WriteLine(finalAmount);
                    break;

                default:
                    Console.WriteLine("Value didn’t match earlier.");
                    break;
                }
            }
        }
 public void SetDescriptionFrom(IPromotion promotion)
 {
     DescriptionField.text = string.Format("{0}\n\n{1}", promotion.name, promotion.Description);
 }
Пример #25
0
 public PromotionB(IPromotion promotion)
 {
     _promotion = promotion;
 }
Пример #26
0
        public double Accept(IPromotion promotion)

        {
            return(promotion.Calculate(this));
        }
Пример #27
0
        public PromotionResult(IPromotion promotion)

        {
            this.promotion = promotion;
        }
Пример #28
0
 public bool ContainsPromotion(IPromotion promotion)
 {
     return(Template.PrerequisiteData.Exists(data => data.Promotion == promotion));
 }
Пример #29
0
 public CalculatePriceTests()
 {
     sut = new GetSecondFree();
 }
Пример #30
0
 public bool RemovePromotion(IPromotion promotion)
 {
     StatePromotionsHaveChanged();
     return(promotions.Remove(promotion));
 }
 public ProductPriceHandler(Func <PromotionTypes, IPromotion> promotions)
 {
     _promotion = promotions(PromotionTypes.Promotion1);
 }
Пример #32
0
 public void AjouterPromotion(IPromotion promotion)
 {
     this._listePromotions.Add(promotion);
 }
Пример #33
0
 public void Add(IPromotion toAdd)
 {
     list.Add(toAdd);
 }