Example #1
0
 public ActionResult Create(FormCollection fc, CMS_Organization obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Organization_DAO objDAO = new CMS_Organization_DAO();
             int ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm cơ quan/tổ chức thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Organization"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm cơ quan/tổ chức 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());
     }
 }
Example #2
0
 public ActionResult Edit(FormCollection fc, CMS_Organization obj, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CMS_Organization_DAO objDAO = new CMS_Organization_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật cơ quan/tổ chức thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Organization"));
             }
             else
             {
                 SetAlert("Cập nhật cơ quan/tổ chức 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());
     }
 }
Example #3
0
 public int Insert(CMS_Organization entity)
 {
     try
     {
         MyContext.CMS_Organization.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Example #4
0
 public bool Update(CMS_Organization entity)
 {
     try
     {
         CMS_Organization obj = MyContext.CMS_Organization.Find(entity.ID);
         obj.Name      = entity.Name;
         obj.ShortName = entity.ShortName;
         obj.ParentID  = entity.ParentID;
         obj.Mobile    = entity.Mobile;
         obj.Email     = entity.Email;
         obj.Website   = entity.Website;
         obj.Address   = entity.Address;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }