示例#1
0
        public virtual JsonResult DynamicGridData(int page, int rows, String search, String sidx, String sord)
        {
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;
            IQueryable <UserGroup> searchQuery = userGroupService.GetSearchQuery(search);
            int totalRecords = userGroupService.GetCount(searchQuery);
            var totalPages   = (int)Math.Ceiling((float)totalRecords / pageSize);
            var userGroups   = searchQuery.OrderBy(sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize).ToList();
            var jsonData     = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = (
                    from userGroup in userGroups
                    select new
                {
                    id = userGroup.Id,
                    cell = new[] { HttpUtility.HtmlEncode(userGroup.Name),
                                   String.Format("{0}<a style=\"margin-left:7px\" href=\"{1}\">{2}</a>",
                                                 AccountsHelper.GetUserGroupRoles(userGroup),
                                                 Url.Action(MVC.Admin.UserGroup.Roles(userGroup.Id)),
                                                 Translate(".Model.UserGroup.Roles")),
                                   String.Format(JqGridConstants.UrlTemplate,
                                                 Url.Action(MVC.Admin.UserGroup.Users(userGroup.Id)),
                                                 Translate(".Model.UserGroup.Users")), String.Format("<a href=\"{0}\"><em class=\"delete\" style=\"margin-left: 10px;\"/></a>",
                                                                                                     Url.Action(MVC.Admin.UserGroup.Remove(userGroup.Id))) }
                }).ToArray()
            };

            return(Json(jsonData));
        }
示例#2
0
        public virtual JsonResult UserGroupsDynamicGridData(int id, int page, int rows, String search, String sidx, String sord)
        {
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;
            var user      = userService.Find(id);

            if (user == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
            }
            IQueryable <UserGroup> searchQuery = userGroupService.GetSearchQuery(search);
            int totalRecords = userGroupService.GetCount(searchQuery);
            var totalPages   = (int)Math.Ceiling((float)totalRecords / pageSize);
            var userGroups   = searchQuery.OrderBy(sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize).ToList();
            var jsonData     = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = (
                    from userGroup in userGroups
                    select new
                {
                    id = userGroup.Id,
                    cell = new[] { userGroup.Name }
                }).ToArray()
            };

            return(Json(jsonData));
        }