public ActionResult Create(Models.ThuongHieu createPdc, HttpPostedFileBase file)
 {
     if (Session["accname"] == null)
     {
         Session["accname"] = null;
         return(RedirectToAction("Login", "Account"));
     }
     else
     {
         if (file != null)
         {
             if (file.ContentLength > 0)
             {
                 try
                 {
                     string nameFile = Path.GetFileName(file.FileName);
                     file.SaveAs(Path.Combine(Server.MapPath("/Images"), nameFile));
                     createPdc.Photo = "/Images/" + nameFile;
                 }
                 catch (Exception)
                 {
                     ViewBag.CreatePdcError = "Không thể chọn ảnh.";
                 }
             }
             var pdc = dbPdc.ThuongHieux.SingleOrDefault(c => c.TenTH.Equals(createPdc.TenTH));
             try
             {
                 if (ModelState.IsValid)
                 {
                     if (pdc != null)
                     {
                         ViewBag.CreatePdcError = "Thương Hiệu đã tồn tại.";
                     }
                     else
                     {
                         aDB.ThemThuongHieu(createPdc);
                         ViewBag.CreatePdcError = "Thêm Thương Hiệu thành công.";
                     }
                 }
             }
             catch (Exception)
             {
                 ViewBag.CreatePdcError = "Không thể thêm Thương Hiệu.";
             }
         }
         else
         {
             ViewBag.HinhAnh = "Vui lòng chọn hình ảnh.";
         }
         return(View());
     }
 }
 public ActionResult Edit(Models.ThuongHieu editPdc, HttpPostedFileBase file)
 {
     if (Session["accname"] == null)
     {
         Session["accname"] = null;
         return(RedirectToAction("Login", "Account"));
     }
     else
     {
         if (file != null)
         {
             if (file.ContentLength > 0)
             {
                 try
                 {
                     string nameFile = Path.GetFileName(file.FileName);
                     file.SaveAs(Path.Combine(Server.MapPath("/Images"), nameFile));
                     editPdc.Photo = "/Images/" + nameFile;
                 }
                 catch (Exception)
                 {
                     ViewBag.EditPdcError = "Không thể chọn ảnh.";
                 }
             }
         }
         try
         {
             if (ModelState.IsValid)
             {
                 aDB.SuaThuongHieu(editPdc);
                 ViewBag.EditPdcError = "Cập nhật Thương Hiệu thành công.";
             }
         }
         catch (Exception)
         {
             ViewBag.EditPdcError = "Không thể cập nhật Thương Hiệu.";
         }
         return(View());
     }
 }