public ActionResult Create([Bind(Include = "ProductID,Name,Description,Price,Category")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public HttpResponseMessage Delete(int id) { SportsDB.TblProducts.Remove(SportsDB.TblProducts.FirstOrDefault(x => x.Id == id)); return(ToJson(SportsDB.SaveChanges())); }
public HttpResponseMessage Put(int id, [FromBody] TblProduct value) { SportsDB.Entry(value).State = EntityState.Modified; return(ToJson(SportsDB.SaveChanges())); }
public HttpResponseMessage Post([FromBody] TblProduct value) { SportsDB.TblProducts.Add(value); return(ToJson(SportsDB.SaveChanges())); }