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(); }
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(); }
public void Edit(Product product) { db.Entry(product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void Delete(Product product) { db.Products.Remove(product); db.SaveChanges(); }
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; } }
public void RemoveLine(Product product) { line.RemoveAll(l => l.Product.ID == product.ID); }
public void ChangeQuantity(Product prod, int quantity) { CartLine cline = line.Find(x => x.Product.ID == prod.ID); cline.Quantity = quantity; }