Ejemplo n.º 1
0
        public ActionResult Add(ProdCategory c)
        {
            CatProdDAO cdao = new CatProdDAO();

            cdao.Insert(c);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult FormUp(string id)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory cat  = cdao.FindById(Convert.ToInt32(id));

            ViewBag.CatId = cat;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Remove(string id)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory c    = cdao.FindById(Convert.ToInt32(id));

            cdao.Remove(c);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        // GET: Category
        public ActionResult Index()
        {
            CatProdDAO           cdao = new CatProdDAO();
            IList <ProdCategory> cat  = cdao.CategoryList();

            ViewBag.Categorys = cat;
            return(View());
        }
Ejemplo n.º 5
0
        public ActionResult Update(ProdCategory c)
        {
            CatProdDAO   cdao = new CatProdDAO();
            ProdCategory cat  = cdao.FindById(Convert.ToInt32(c.Id));

            cat.Name        = c.Name;
            cat.Description = c.Description;
            cdao.Update();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        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"));
        }
Ejemplo n.º 10
0
        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"));
            }
        }