public void AddtoProductInPromotionList(int quantity, int productID, int promotionID, List <ProductInPromotion> productInPromotion)
        {
            ProductInPromotion p = new ProductInPromotion();

            p.ProductID   = productID;
            p.PromotionID = promotionID;
            p.QuantityOfProductsInPromotion = quantity;
            productInPromotion.Add(p);
        }
Esempio n. 2
0
        public ProductInPromotion DeleteProductPromotion(int productPromotionID)
        {
            ProductInPromotion dbEntry = context.ProductsInPromotion.Find(productPromotionID);

            if (dbEntry != null)
            {
                context.ProductsInPromotion.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
Esempio n. 3
0
 public void SaveProductPromotion(ProductInPromotion productPromotion)
 {
     if (productPromotion.ProductInPromotionID == 0)
     {
         context.ProductsInPromotion.Add(productPromotion);
     }
     else
     {
         ProductInPromotion dbEntry = context.ProductsInPromotion.Find(productPromotion.ProductInPromotionID);
         if (dbEntry != null)
         {
             //ProductPromotion
             dbEntry.ProductID   = productPromotion.ProductID;
             dbEntry.PromotionID = productPromotion.PromotionID;
             dbEntry.QuantityOfProductsInPromotion = productPromotion.QuantityOfProductsInPromotion;
         }
     }
     context.SaveChanges();
 }