예제 #1
0
        public async Task <ApiPagedListOutput <RoleModel> > GetListAsync([FromQuery] RoleApiListQueryModel model)
        {
            var list = await _roleManager.GetRolesPagedListAsync(new RolePagedListInputModel()
            {
                SearchTerm            = model.SearchTerm,
                Limit                 = model.Limit,
                Skip                  = model.Skip,
                IncludePermissionKeys = model.IncludePermissionKeys,
            });

            return(new ApiPagedListOutput <RoleModel>(list.TotalCount, list.Select(t => _roleFactory.ToModel(t, new RoleModel())).ToList()));
        }
예제 #2
0
        public async Task <ApiPagedListOutput <UserModel> > GetListAsync([FromQuery]  UserApiPagedListQueryModel model)
        {
            var limit = model.Limit;
            var skip  = model.Skip;

            var list = await _userManager.GetUserPagedListAsync(new UserPagedListInputModel()
            {
                Limit        = model.Limit,
                Skip         = model.Skip,
                SearchTerm   = model.SearchTerm,
                IncludeRoles = model.IncludeRoles,
                IncludeRolePermissionKeys = false,
                Orders = model.Orders?.Where(t => t.Field != null).ToDictionary(t => t.Field, t => t.Order),
            });

            return(new ApiPagedListOutput <UserModel>(list.Count, list.Select(t =>
            {
                var m = _userFactory.ToModel(t, new UserModel());
                m.Roles = t.UserRoles?.Select(t => _roleFactory.ToModel(t.Role, new RoleModel()));

                return m;
            }).ToList()));
        }