示例#1
0
        public ActionResult ThemSanPham(Product pro, HttpPostedFile img)
        {
            var path     = "";
            var filename = "";

            if (ModelState.IsValid)
            {
                if (img != null)
                {
                    filename = img.FileName;
                    path     = Path.Combine(Server.MapPath("~/Content/Images/Product/"), filename);

                    img.SaveAs(path);
                    pro.Image = filename;
                }
                QuanLy ql = new QuanLy();
                ql.AddProduct(pro);

                return(RedirectToAction("Product"));
            }
            ViewBag.IDbrand = new SelectList(__db.Brands, "ID", "Name", pro.ID);
            ViewBag.IDType  = new SelectList(__db.Types, "ID", "Name", pro.ID);
            return(View(pro));
        }