Пример #1
0
 public ActionResult Create(FormCollection fc, CMS_Links obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         if (ModelState.IsValid)
         {
             CMS_Links_DAO objDAO   = new CMS_Links_DAO();
             int           ReturnID = objDAO.Insert(obj);
             if (ReturnID > 0)
             {
                 SetAlert("Thêm liên kết thành công", AlertType.Success);
                 return(RedirectToAction("index", "CMS_Links"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới 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());
     }
 }
Пример #2
0
 public ActionResult Edit(FormCollection fc, CMS_Links obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         if (ModelState.IsValid)
         {
             CMS_Links_DAO objDAO     = new CMS_Links_DAO();
             CSF_Users_DAO objUserDao = new CSF_Users_DAO();
             if (objDAO.Update(obj))
             {
                 SetAlert("Cập nhật thành công", AlertType.Success);
                 return(RedirectToAction("Index", "CMS_Links"));
             }
             else
             {
                 SetAlert("Cập nhật 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());
     }
 }
Пример #3
0
 public int Insert(CMS_Links entity)
 {
     try
     {
         MyContext.CMS_Links.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Пример #4
0
 public bool Update(CMS_Links entity)
 {
     try
     {
         CMS_Links obj = MyContext.CMS_Links.Find(entity.ID);
         obj.Name    = entity.Name;
         obj.Url     = entity.Url;
         obj.Picture = entity.Picture;
         obj.Shows   = entity.Shows;
         obj.Order   = entity.Order;
         MyContext.Entry(obj).State = EntityState.Modified;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }