예제 #1
0
 public ActionResult Edit(int id)
 {
     try
     {
         CSF_Users_DAO objUsersDAO = new CSF_Users_DAO();
         var           user        = objUsersDAO.GetUserByID(id);
         if (user == null)
         {
             return(RedirectToAction("Index", "QT_Users"));
         }
         CSF_Roles_DAO objRolesDAO = new CSF_Roles_DAO();
         var           roles       = objRolesDAO.GetAll();
         TempData["Roles"] = roles.ToList();
         TempData.Keep("Roles");
         //Hiển thị Role đã có của User
         CSF_UserRole_DAO objUserRoleDAO = new CSF_UserRole_DAO();
         List <CSF_UserRole_GetByUser_Result> userRole = objUserRoleDAO.GetListRoleByUserID(id);
         TempData["userRole"] = userRole;
         TempData.Keep("userRole");
         return(View(user));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
예제 #2
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());
     }
 }
예제 #3
0
 public ActionResult Edit(int id)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Roles_DAO objRolesDAO = new CSF_Roles_DAO();
         var           role        = objRolesDAO.GetRoleByID(id);
         return(View(role));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
예제 #4
0
 public ActionResult Create()
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Roles_DAO objRolesDAO = new CSF_Roles_DAO();
         var           roles       = objRolesDAO.GetAll();
         TempData["Roles"] = roles.ToList();
         TempData.Keep("Roles");
         return(View());
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
예제 #5
0
 public ActionResult Index(string searchString)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Roles_DAO objRolesDAO = new CSF_Roles_DAO();
         //var roles = objRolesDAO.GetAll();
         var roles = objRolesDAO.Search(searchString);
         ViewBag.SearchString = searchString;
         return(View(roles));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), AlertType.Error);
         Logs.WriteLog(ex);
         return(View());
     }
 }
예제 #6
0
 public JsonResult Delete(int id)
 {
     try
     {
         //if (!this.HasPermission) return RedirectToAction("Unauthorized", "Home");
         CSF_Roles_DAO objRolesDAO = new CSF_Roles_DAO();
         if (objRolesDAO.Delete(id))
         {
             SetAlert("Xóa nhóm người dùng thành công", AlertType.Success);
             return(Json(new { status = true, message = "" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { status = false, message = "Nhóm này đang được sử dụng, không được phép xóa!" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(Json(new { status = false, message = "Lỗi: " + ex }, JsonRequestBehavior.AllowGet));
     }
 }