public async Task <SearchResult <Role> > Handle(GetUserRoles request, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var userUid = request?.UserUid ?? throw new ArgumentNullException(nameof(request)); using (var db = _dbContextFactory.Create()) { var query = from userRole in db.GetTable <DbUserRole>() join role in db.GetTable <DbRole>() on userRole.RoleId equals role.Id where userRole.UserId == userUid select role; var data = await Materialize(query.Apply(request, x => x.Name), cancellationToken); return(new SearchResult <Role> { TotalCount = query.GetTotalCount(request), Rows = data }); } }
public async Task <SearchResult <Role> > ListRoles(GetUserRoles request) { return(await _mediator.Send(request)); }