예제 #1
0
        public IPagedList <RoleModel> GetRoles(RoleCndModel cnd)
        {
            var query = from x in _roleRepository.Table.Where(x => x.Type != RoleTypeEnum.SuperAdminRole)
                        select new RoleModel
            {
                Id          = x.Id,
                Name        = x.Name,
                Active      = x.Active,
                ParentId    = x.ParentId,
                CreatedTime = x.CreatedTime,
                Type        = x.Type
            };

            if (cnd.Id > 0)
            {
                query = query.Where(x => x.Id == cnd.Id);
            }
            if (!string.IsNullOrEmpty(cnd.Name))
            {
                query = query.Where(x => x.Name == cnd.Name);
            }
            if (cnd.Type.HasValue)
            {
                query = query.Where(x => x.Type == cnd.Type.Value);
            }
            if (cnd.Active.HasValue)
            {
                query = query.Where(x => x.Active == cnd.Active.Value);
            }
            if (cnd.Start.HasValue)
            {
                var start = cnd.Start.Value.Date;
                query = query.Where(x => x.CreatedTime >= start);
            }
            if (cnd.End.HasValue)
            {
                query = query.Where(x => x.CreatedTime < cnd.End);
            }
            return(new PagedList <RoleModel>(query.OrderByDescending(x => x.Id), cnd.PageIndex, cnd.PageSize));
        }
예제 #2
0
        public ActionResult AjaxGetRoleList(RoleCndModel cnd)
        {
            var data = _roleService.GetRoles(cnd);

            return(Json(new { rows = data, total = data.TotalCount }, JsonRequestBehavior.AllowGet));
        }