Skip to content

Commit

Permalink
#2 Добавил получение записей пользователей роли
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryGhost committed Mar 1, 2020
1 parent 1dabe85 commit 296267c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Idone/Idone.Security/EnterPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public EnterPoint(IServiceProvider serviceProvider)
/// <inheritdoc />
public Either<Error, DtoGridUser> GetGridRoleUsers(DtoGridQueryRoleUser gridQueryRoleUser)
{
throw new NotImplementedException();
var result = _userService.GetGridRoleUsers(gridQueryRoleUser);

return result;
}

/// <inheritdoc />
Expand Down
14 changes: 14 additions & 0 deletions Idone/Idone.Security/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,19 @@ public UserService(AppContext appContext)

return Right<Error, DtoGridRole>(result);
}

public Either<Error, DtoGridUser> GetGridRoleUsers(DtoGridQueryRoleUser gridQuery)
{
var dbQuery = _appContext.UserRoles.AsQueryable();
var optionFilter = gridQuery.Filter;

optionFilter.Bind(filter => dbQuery = dbQuery.Where(userRole => userRole.User.Id == filter.Id));

var rows = dbQuery.Paginate(gridQuery.Pagination).Select(userRole =>
_appContext.Users.Find(userRole.User.Id)).Where(user => user != null).Select(user => new DtoRowUser(user.Email, user.DisplayName, user.Id));
var result = new DtoGridUser(rows, _appContext.Users.Count());

return Right<Error, DtoGridUser>(result);
}
}
}

0 comments on commit 296267c

Please sign in to comment.