public bool Update(Product product) { using (var productContext = new ProductCatalogContext()) { productContext.Products.AddOrUpdate(x => x.productId, product); productContext.SaveChanges(); return(true); } }
public bool Post(Product product) { using (var productContext = new ProductCatalogContext()) { productContext.Products.Add(product); productContext.SaveChanges(); return(true); } }
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); } }