Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Created February 2, 2021 16:32
Show Gist options
  • Save SibeeshVenu/d0483db658f83d51053b70f4e07a8899 to your computer and use it in GitHub Desktop.
Save SibeeshVenu/d0483db658f83d51053b70f4e07a8899 to your computer and use it in GitHub Desktop.
public async Task < IEnumerable < UserDto >> GetUserList(Guid selectedTenant) {
_logger.LogInformation($ "The method {nameof(GetUserList)} is called");
var appUsers = await _adminRepository.GetUsersWithRole(selectedTenant);
if (!appUsers.Any()) throw AdminException.FromCode(ErrorCode.NoUsersInDbSelectedTenant);
var users = await _graphFacade.GetUsersUsingGraph(selectedTenant);
if (!users.Any()) throw AdminException.FromCode(ErrorCode.NoUsersInAdSelectedTenant);
var combinedList = appUsers.Join(users, app = >app.UserId, graph =>new Guid(graph.Id), (app, graph) = >new UserDto {
DisplayName = graph.DisplayName,
UserName = graph.UserPrincipalName,
Role = app.UserRole,
UserId = app.UserId
}).ToList < UserDto > ();
_logger.LogInformation($ "Succesfully executed the method {nameof(GetUserList)}");
return combinedList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment