product business

This commit is contained in:
Aneliya Konarcheva
2021-03-07 10:13:23 +02:00
parent 39e9737476
commit 219b0483f6

View File

@@ -38,7 +38,28 @@ namespace LuminousSales.Business
public void Update(Product product)
{
using (productContext = new ProductContext())
{
var item = productContext.Products.Find(product.Id);
if (item != null)
{
productContext.Entry(item).CurrentValues.SetValues(product);
productContext.SaveChanges();
}
}
}
public void Delete(int id)
{
using (productContext = new ProductContext())
{
var product = productContext.Products.Find(id);
if (product != null)
{
productContext.Products.Remove(product);
productContext.SaveChanges();
}
}
}
}