public ActionResult Edit(int id)
        {
            DataContextDB dataContextDB = new DataContextDB();
            Product       productedit   = dataContextDB.Products.Single(cat => cat.ProductId == id);

            return(View(productedit));
        }
        public ActionResult Edit(int?id)
        {
            DataContextDB dataContextDB = new DataContextDB();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var EdietProduct = dataContextDB.Products.Find(id);

            if (TryUpdateModel(EdietProduct, "",
                               new string[] { "Name", "Description", "Price" }))
            {
                try
                {
                    dataContextDB.SaveChanges();

                    return(RedirectToAction("Index", "Home"));
                }
                catch (RetryLimitExceededException)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            return(View(EdietProduct));
        }
        public ActionResult Index(int CategoryId)
        {
            DataContextDB  dataContextDB = new DataContextDB();
            List <Product> product       = dataContextDB.Products.Where(emp => emp.CategoryId == CategoryId).ToList();

            return(View(product));
        }
        public ActionResult Delete(int id)
        {
            DataContextDB dataContextDB = new DataContextDB();
            Product       productdelet  = dataContextDB.Products.Single(cat => cat.ProductId == id);

            dataContextDB.Products.Remove(productdelet);
            dataContextDB.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }