示例#1
0
        public JsonResult GetUserGroups(int limit, int offset, string userGroupName, int enable)
        {
            Expression <Func <UserGroups, bool> > wh = c => true;

            if (!string.IsNullOrEmpty(userGroupName))
            {
                wh = wh.And(c => c.GroupName.Contains(userGroupName));
            }
            if (enable >= 0)
            {
                var yesOrNot = enable != 0;
                wh = wh.And(c => c.Enabled == yesOrNot);
            }

            int total;
            var lstGroups = _userGroupService.GetPageList(offset, limit, out total, wh, t => t.OrderSort, t => t.Id);
            var result    = new List <UserGroupVM>();

            if (lstGroups.Count > 0)
            {
                result = lstGroups.Select(t => new UserGroupVM()
                {
                    Id          = t.Id,
                    GroupName   = t.GroupName,
                    Description = t.Description,
                    Enabled     = t.Enabled,
                    UpdateDate  = t.UpdateDate
                }).ToList();
            }
            return(Json(new { total = total, rows = result }, JsonRequestBehavior.AllowGet));
        }