コード例 #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());
     }
 }