public ActionResult DeleteConfirmed(int id) { tcProduct tcProduct = db.tcProducts.Find(id); db.tcProducts.Remove(tcProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,Cost,Price,Stock")] tcProduct tcProduct) { if (ModelState.IsValid) { db.Entry(tcProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tcProduct)); }
public ActionResult Create([Bind(Include = "Id,Name,Cost,Price,Stock")] tcProduct tcProduct) { if (ModelState.IsValid) { db.tcProducts.Add(tcProduct); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tcProduct)); }
public tcProduct GetProduct(int id) { if (!productExists(id)) { return(null); } var tcProduct = db.tcProducts.Find(id); var product = new tcProduct() { Id = tcProduct.Id, Name = tcProduct.Name, Cost = tcProduct.Cost, Price = tcProduct.Price, Stock = tcProduct.Stock }; return(product); }
// GET: tcProducts/Edit/5 public ActionResult Edit(int?id) { if (IsAllowed() == false) { return(RedirectToAction("Index", "Login")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tcProduct tcProduct = db.tcProducts.Find(id); if (tcProduct == null) { return(HttpNotFound()); } return(View(tcProduct)); }