Exemplo n.º 1
0
 public override IEnumerable <ProductModel> GetCampaignProducts()
 {
     if (Model != null)
     {
         var model         = (IEnumerable <PriceByProductCampaignItemModel>)Model;
         var campaignModel = new PriceByProductCampaignModel(model);
         IList <EntityProduct> products      = campaignModel.Select(item => Repository.Data.Get <EntityProduct>().Where(x => x.Id == item.Id && x.Published).FirstOrDefault().Value).ToList();
         IList <ProductModel>  productModels = products.ConvertAll().ToList();
         ApplyCampaign(productModels);
         return(productModels);
     }
     return(new List <ProductModel>());
 }
Exemplo n.º 2
0
        public override void ApplyCampaign(IList <ProductModel> products)
        {
            foreach (var product in products.Where(x => x.Published))
            {
                var model         = (IEnumerable <PriceByProductCampaignItemModel>)Model;
                var campaignModel = new PriceByProductCampaignModel(model);

                if (campaignModel.ContainsKey(product.Id))
                {
                    product.IsInCampaign  = true;
                    product.CampaignPrice = campaignModel[product.Id].CampaignPrice;
                }
            }
        }