Exemple #1
0
        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;
            }
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        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();
 }