Esempio n. 1
0
 public void Create(Product product, ProductViewModel prod = null)
 {
     if (product != null)
     {
         db.Products.Add(product);
     }
     else
     {
         var newP = new Product();
         newP.Sortindex = newP.ID + 1;
         newP.ProductName = prod.ProductName;
         newP.Description = prod.Description;
         newP.MatForm = prod.MatForm;
         newP.MatIronForm = prod.MatIronForm;
         newP.ProdTime = prod.ProdTime;
         newP.Block = prod.Block;
         newP.Season = prod.Season;
         newP.Coupling = prod.Coupling;
         newP.MatProd = prod.MatProd;
         newP.Channel = prod.Channel;
         newP.Hardness = prod.Hardness;
         newP.Size = prod.Size;
         newP.ProductType = prod.ProductType;
         newP.Price = prod.Price;
         newP.CategoryID = prod.CategoryID;
         db.Products.Add(newP);
     }
     db.SaveChanges();
 }
Esempio n. 2
0
        public void Create(Product product,int quantity, int orderId)
        {
            OrderItem oitem = new OrderItem();

            oitem.OrderID = orderId;
            oitem.ProductName = product.ProductName;
            oitem.Quantity = quantity;
            oitem.Price = product.Price;
            oitem.Category = db.Categories.Find(product.CategoryID).CategoryName;
            oitem.Description = product.Description;
            db.OrderItems.Add(oitem);
            db.SaveChanges();
        }
Esempio n. 3
0
 public void Edit(Product product)
 {
     db.Entry(product).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Esempio n. 4
0
 public void Delete(Product product)
 {
     db.Products.Remove(product);
     db.SaveChanges();
 }
Esempio n. 5
0
        public void AddItem(Product product, int quantity = 1)
        {
            CartLine cline = line.Find(x => x.Product.ID == product.ID);
            //.Where(x => x.Product.ID == product.ID)
            //.FirstOrDefault();

            if (cline == null)
            {
                line.Add(new CartLine { Product = product, Quantity = quantity });
            }
            else
            {
                cline.Quantity += quantity;
            }
        }
Esempio n. 6
0
 public void RemoveLine(Product product)
 {
     line.RemoveAll(l => l.Product.ID == product.ID);
 }
Esempio n. 7
0
 public void ChangeQuantity(Product prod, int quantity)
 {
     CartLine cline = line.Find(x => x.Product.ID == prod.ID);
     cline.Quantity = quantity;
 }