コード例 #1
0
 public bool Update(Product product)
 {
     using (var productContext = new ProductCatalogContext())
     {
         productContext.Products.AddOrUpdate(x => x.productId, product);
         productContext.SaveChanges();
         return(true);
     }
 }
コード例 #2
0
 public bool Post(Product product)
 {
     using (var productContext = new ProductCatalogContext())
     {
         productContext.Products.Add(product);
         productContext.SaveChanges();
         return(true);
     }
 }
コード例 #3
0
 public bool Remove(string id)
 {
     using (var productContext = new ProductCatalogContext())
     {
         Product prod = productContext.Products.Where(x => x.productId == id).SingleOrDefault();
         productContext.Products.Remove(prod);
         productContext.SaveChanges();
         return(true);
     }
 }