// GET: Category public ActionResult Index() { CatProdDAO cdao = new CatProdDAO(); IList <ProdCategory> cat = cdao.CategoryList(); ViewBag.Categorys = cat; return(View()); }
public ActionResult Index() { ProductDAO pdao = new ProductDAO(); IList <Product> prod = pdao.ProductList(); ViewBag.Products = prod; CatProdDAO cdao = new CatProdDAO(); IList <ProdCategory> cat = cdao.CategoryList(); ViewBag.Categorys = cat; return(View()); }
public ActionResult Details(int Id) { ProductDAO pdao = new ProductDAO(); CatProdDAO cdao = new CatProdDAO(); IList <ProdCategory> cat = cdao.CategoryList(); Product p = pdao.FindById(Convert.ToInt32(Id)); ProdCategory catid = cdao.FindById(Convert.ToInt32(p.CategoryId)); ViewBag.CatId = catid; ViewBag.ProdId = p; return(View()); }
public ActionResult FormUp(string id) { ProductDAO pdao = new ProductDAO(); CatProdDAO cdao = new CatProdDAO(); IList <ProdCategory> cat = cdao.CategoryList(); ViewBag.Categorys = cat; Product prod = pdao.FindById(Convert.ToInt32(id)); ViewBag.ProdId = prod; ProdCategory catid = cdao.FindById(Convert.ToInt32(prod.CategoryId)); ViewBag.CatId = catid; return(View()); }
public ActionResult Update(Product p) //string id, string name, string description, float price, int quantity, int category { ProductDAO pdao = new ProductDAO(); CatProdDAO cdao = new CatProdDAO(); IList <ProdCategory> cat = cdao.CategoryList(); ViewBag.Categorys = cat; Product prod = pdao.FindById(Convert.ToInt32(p.Id)); prod.Name = p.Name; prod.Description = p.Description; prod.CategoryId = p.CategoryId; prod.Price = p.Price; prod.Quantity = p.Quantity; pdao.Update(); return(RedirectToAction("Index")); }
public ActionResult Add(Product p) { ProductDAO pdao = new ProductDAO(); if (p.CategoryId.Equals(1) && p.Price < 20000) { ModelState.AddModelError("p.SUVPrice", "The SUV price must be higher than $20k"); } if (ModelState.IsValid) { pdao.Insert(p); return(RedirectToAction("Index")); } else { CatProdDAO cdao = new CatProdDAO(); ViewBag.Categorys = cdao.CategoryList(); ViewBag.Class = "alert alert-danger"; return(View("frmAdd")); } }