public ActionResult Create(Supplier supplier)
 {
     try
     {
         if (ModelState.IsValid)
         {
             DbContext.Suppliers.Add(supplier);
             if (DbContext.SaveChanges() > 0)
                 return Redirect(null);
             ModelState.AddModelError("", "Đã có lỗi xảy ra. Vui lòng thử lại sau.");
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         ex.Write(LogPath);
     }
     return View(supplier);
 }
        public ActionResult Edit(Supplier supplier)
        {
            var supplierDb = DbContext.Suppliers.Find(supplier.SupplierId);
            if (supplierDb == null)
            {
                ModelState.AddModelError(string.Empty, "Không thể lưu thay đổi, nhà cung cấp này đã bị xóa");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    TryUpdateModel(supplierDb);
                    DbContext.Entry(supplierDb).State = EntityState.Modified;
                    if (DbContext.SaveChanges() > 0)
                    {
                        return Redirect(null);
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    ex.Write(LogPath);
                }
            }
            return View(supplierDb);
        }