Esempio n. 1
0
 public ActionResult Create(CSF_Roles role)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         if (ModelState.IsValid)
         {
             CSF_Roles_DAO objRolesDAO  = new CSF_Roles_DAO();
             int           ReturnRoleID = objRolesDAO.Insert(role);
             if (ReturnRoleID > 0)
             {
                 SetAlert("Thêm nhóm người dùng thành công", AlertType.Success);
                 return(RedirectToAction("Index", "QT_Roles"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm nhóm người dùng không thành công");
             }
         }
         return(View("Index"));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
Esempio n. 2
0
 public int Insert(CSF_Roles entity)
 {
     try
     {
         MyContext.CSF_Roles.Add(entity);
         MyContext.SaveChanges();
         return(entity.ID);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         throw;
     }
 }
Esempio n. 3
0
 public bool Update(CSF_Roles entity)
 {
     try
     {
         var role = MyContext.CSF_Roles.Find(entity.ID);
         role.Name        = entity.Name;
         role.Description = entity.Description;
         role.IsAdmin     = entity.IsAdmin;
         MyContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(false);
     }
 }