Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            tcProduct tcProduct = db.tcProducts.Find(id);

            db.tcProducts.Remove(tcProduct);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 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));
 }
Пример #3
0
        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));
        }
Пример #4
0
        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);
        }
Пример #5
0
        // 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));
        }