Beispiel #1
0
 public Product  AddProduct(Product product)
 {
     using (var data = new Models.MarketDbContext())
     {
         data.Products.Add(product);
         data.SaveChanges();
     }
     return(product);
 }
Beispiel #2
0
 public Models.Product DeleteProduct(int id)
 {
     Models.Product products = new Models.Product();
     using (var data = new Models.MarketDbContext())
     {
         products = data.Products.FirstOrDefault(x => x.Id == id);
         data.Products.Remove(products);
         data.SaveChanges();
     }
     return(products);
 }