Ejemplo n.º 1
0
 public ActionResult SuaSanPham(Product pro, ProductDetail detail)
 {
     if (ModelState.IsValid)
     {
         if (pro.ImageUpload != null)
         {
             string filename  = Path.GetFileNameWithoutExtension(pro.ImageUpload.FileName);
             string extension = Path.GetExtension(pro.ImageUpload.FileName);
             filename  = filename + extension;
             pro.Image = "~/Content/Images/Product/" + filename;
             pro.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/Content/Images/Product/"), filename));
         }
         QuanLy ql = new QuanLy();
         ql.UpdateProduct(pro);
         __db.Entry(pro).State = EntityState.Modified;
         __db.SaveChanges();
         ViewBag.IDBrand = new SelectList(__db.Brands, "ID", "Name", pro.ID);
         ViewBag.IDType  = new SelectList(__db.Types, "ID", "Name", pro.ID);
         return(RedirectToAction("Product"));
     }
     return(View(pro));
 }