public ActionResult EditProduct(InkeyProduct inkProduct) { try { using (var db = new BePreferencesEntities()) { db.Entry(inkProduct).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("ProductManager")); } catch (Exception) { throw; } }
public ActionResult RemoveProduct(int prodId) { try { using (var db = new BePreferencesEntities()) { InkeyProduct newProd = db.InkeyProducts.FirstOrDefault(p => p.InkeyProductsId == prodId); db.InkeyProducts.Remove(newProd); db.SaveChanges(); return(RedirectToAction("ProductManager")); } } catch (Exception) { throw; } }
public ActionResult AddNewProduct(ProductManagerViewModel newProdMod) { try { using (var db = new BePreferencesEntities()) { InkeyProduct newProd = newProdMod.NewProduct; db.InkeyProducts.Add(newProd); db.SaveChanges(); return(RedirectToAction("ProductManager")); } } catch (Exception ex) { throw ex; } }
public ProductManagerViewModel() { AllProducts = db.InkeyProducts.ToList(); NewProduct = new InkeyProduct(); }