public ActionResult Create(FormCollection fc, CMS_AreaOfDocument obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_AreaOfDocument_DAO objDAO = new CMS_AreaOfDocument_DAO();
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm lĩnh vực văn bản thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_AreaOfDocument"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm lĩnh vực văn bản không thành công");
             }
             return(View("Index"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public ActionResult Edit(FormCollection fc, CMS_AreaOfDocument obj, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_AreaOfDocument_DAO objDAO = new CMS_AreaOfDocument_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật lĩnh vực văn bản thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_AreaOfDocument"));
             }
             else
             {
                 SetAlert("Cập nhật lĩnh vực văn bản không thành công", AlertType.Error);
             }
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
 public bool Update(CMS_AreaOfDocument entity)
 {
     try
     {
         MyContext.Entry(entity).State = EntityState.Modified;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
 public int Insert(CMS_AreaOfDocument entity)
 {
     try
     {
         MyContext.CMS_AreaOfDocument.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }