Example #1
0
 public ActionResult Create(FormCollection fc, CSF_RoleFunction obj)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         if (ModelState.IsValid)
         {
             CSF_RoleFunction_DAO objRFDAO = new CSF_RoleFunction_DAO();
             if (objRFDAO.CheckExist_RF(obj))
             {
                 SetAlert("Nhóm - Chức năng đã tồn tại!", AlertType.Error);
             }
             else
             {
                 int ReturnID = objRFDAO.Insert(obj);
                 if (ReturnID > 0)
                 {
                     SetAlert("Thêm Nhóm - Chức năng thành công", AlertType.Success);
                     return(RedirectToAction("Index", "QT_RoleFunction"));
                 }
                 else
                 {
                     SetAlert("Thêm Nhóm - Chức năng không thành công", AlertType.Error);
                 }
             }
         }
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Example #2
0
 public int Insert(CSF_RoleFunction entity)
 {
     try
     {
         MyContext.CSF_RoleFunction.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Example #3
0
 public bool Update(CSF_RoleFunction entity)
 {
     try
     {
         MyContext.Entry(entity).State = EntityState.Modified;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }
Example #4
0
 public bool CheckExist_RF(CSF_RoleFunction entity)
 {
     try
     {
         var rf = MyContext.CSF_RoleFunction.Where(x => x.RoleID == entity.RoleID && x.FunctionID == entity.FunctionID).First();
         if (rf != null)
         {
             if (entity.ID != rf.ID)
             {
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }