Exemple #1
0
        public ActionResult AddToCategory(AddToCategoryModel model)
        {
            var category = db.Categories.Find(model.categoryId);
            var product  = db.Products.Find(model.productId);

            category.products.Add(product);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult AddToCategory(int id)
        {
            AddToCategoryModel model = new AddToCategoryModel();

            model.categoryId     = id;
            model.products       = db.Products.ToList();
            ViewBag.CategoryName = db.Categories.Find(id).CategoryName;
            return(View(model));
        }