public ActionResult List_user_permission(string user_name, string type, string act, string ctrl, string type_act)
        {
            UserModels    userModels      = new UserModels();
            var           permission_view = new Web.Areas.Admin.ViewModels.List_user_permission_view();
            StringBuilder sb = new StringBuilder();

            if (string.IsNullOrEmpty(type))
            {
                type = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString() : CommonGlobal.RoleAdmin;
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_user_permission";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminUser";
            }

            if (user_name == null)
            {
                user_name = Request.QueryString["user_name"] != null ? Request.QueryString["user_name"].ToString() : string.Empty;
            }

            List <PagePermission> lstPagePermission = userModels.GetListPermissionByUser(user_name);

            permission_view.List_permission = lstPagePermission;
            permission_view.TotalPage       = lstPagePermission.Where(p => p.Parent_ID > 0).ToList().Count;
            permission_view.User_name       = user_name;
            permission_view.Type            = type;
            permission_view.Type_act        = type_act;

            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_user", ctrl = "adminUser", type = type, page = "1" }) + "\"><span><span>Danh sách Admin</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_user", ctrl = "adminUser", type = type, type_act = CommonGlobal.Edit, user_name = user_name }) + "\"><span><span>Cập nhật Admin</span></span></a></li>");
            sb.Append("<li class=\"active\"><a href=\"#\"><span>Page Permission</span></a></li>");
            permission_view.Html_link_tab = sb.ToString();

            ////action and parent action
            permission_view.Act               = act;
            permission_view.Ctrl              = ctrl;
            permission_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            permission_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_user_permission", permission_view));
        }
        public ActionResult List_user_permission(FormCollection collection, string type, string act, string ctrl, string type_act)
        {
            UserModels userModels      = new UserModels();
            var        permission_view = new Web.Areas.Admin.ViewModels.List_user_permission_view();

            this.TryUpdateModel(permission_view);
            StringBuilder sb = new StringBuilder();

            if (string.IsNullOrEmpty(type))
            {
                type = collection["type"].ToString();
            }

            if (string.IsNullOrEmpty(act))
            {
                act = Request.QueryString["act"] != null ? Request.QueryString["act"].ToString() : "list_user_permission";
            }

            if (string.IsNullOrEmpty(ctrl))
            {
                ctrl = Request.QueryString["ctrl"] != null ? Request.QueryString["ctrl"].ToString() : "adminUser";
            }

            string user_name = collection["user_name"].ToString();

            int totalPage = 0;

            if (!string.IsNullOrEmpty(collection["totalPage"]))
            {
                totalPage = int.Parse(collection["totalPage"]);
            }

            for (int i = 1; i <= totalPage; ++i)
            {
                string index = "page_" + i;
                if (!string.IsNullOrEmpty(collection[index]))
                {
                    C_UserPermission objUserPermission = new C_UserPermission();
                    int pageID = int.Parse(collection[index]);
                    objUserPermission.page_id = pageID;
                    objUserPermission.user    = user_name;

                    string strAdd = collection["add_" + pageID];
                    if (strAdd.Contains("true"))
                    {
                        objUserPermission.add = true;
                    }
                    else
                    {
                        objUserPermission.add = false;
                    }

                    string strEdit = collection["edit_" + pageID];
                    if (strEdit.Contains("true"))
                    {
                        objUserPermission.edit = true;
                    }
                    else
                    {
                        objUserPermission.edit = false;
                    }

                    string strDelete = collection["delete_" + pageID];
                    if (strDelete.Contains("true"))
                    {
                        objUserPermission.del = true;
                    }
                    else
                    {
                        objUserPermission.del = false;
                    }

                    string strView = collection["view_" + pageID];
                    if (strView.Contains("true"))
                    {
                        objUserPermission.view = true;
                    }
                    else
                    {
                        objUserPermission.view = false;
                    }

                    userModels.UpdatePermission(objUserPermission);
                }
            }

            permission_view.Message = "Cập nhật thành công.";

            List <PagePermission> lstPagePermission = userModels.GetListPermissionByUser(user_name);

            permission_view.List_permission = lstPagePermission;
            permission_view.TotalPage       = lstPagePermission.Count;
            permission_view.User_name       = user_name;
            permission_view.Type            = type;

            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_user", ctrl = "adminUser", type = type, page = "1" }) + "\"><span><span>Danh sách Admin</span></span></a></li>");
            sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "change_user", ctrl = "adminUser", type = type, type_act = CommonGlobal.Edit, user_name = user_name }) + "\"><span><span>Cập nhật Admin</span></span></a></li>");
            sb.Append("<li class=\"active\"><a href=\"#\"><span>Page Permission</span></a></li>");
            permission_view.Html_link_tab = sb.ToString();

            ////action and parent action
            permission_view.Parent_action     = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString();
            permission_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString();

            return(this.PartialView("../control/list_user_permission", permission_view));
        }