public void AddProduct(ProductModel product) { LS_Product productEntity = new LS_Product(); productEntity.ImagePath = product.ImagePath; productEntity.Name = product.Name; productEntity.Price = product.Price; productEntity.Description = product.Description; using (DBDVEntities db = new DBDVEntities()) { db.LS_Product.Add(productEntity); db.SaveChanges(); } }
public void AddOrder(ProductModel product, string id) { LS_Orders order = new LS_Orders(); order.Id = id; order.ProductId = product.Id; order.Quantity = product.Quantity; order.Total = product.Quantity * product.Price; using (DBDVEntities db = new DBDVEntities()) { db.LS_Orders.Add(order); db.SaveChanges(); } }
public bool DeleteProduct(int productId) { using (DBDVEntities db = new DBDVEntities()) { var result = db.LS_Product.SingleOrDefault(b => b.id == productId); if (result != null) { result.IsDeleted = true; db.SaveChanges(); return(true); } return(false); } }