private async Task <IRavenQueryable <BacklogItemIndexedForList> > ApplyFilters(IRavenQueryable <BacklogItemIndexedForList> query, BacklogItemListGetRequest dto) { if (dto.Types?.Where(v => v.HasValue).Select(v => v !.Value).ToList() is var types && types?.Any() == true) { query = query.Where(t => t.Type.In(types)); } if (dto.States?.Where(v => v.HasValue).Select(v => v !.Value).ToList() is var states && states?.Any() == true) { query = query.Where(t => t.State.In(states)); } if (dto.Tags?.Any() == true) { foreach (var tag in dto.Tags.Where(t => !string.IsNullOrEmpty(t))) { query = query.Where(e => e.Tags !.Contains(tag)); // Note: [Tags] is a nullable field, but when the LINQ gets converted to RQL the potential NULLs get handled } } if (dto.CurrentUserRelation.HasValue) { var userId = _userResolver.GetCurrentUserId(); query = dto.CurrentUserRelation.Value switch { // Note: [MentionedUser] & [ModifiedByUser] are nullable fields, but when the LINQ gets converted to RQL the potential NULLs get handled CurrentUserRelations.MentionsOf => query.Where(t => t.MentionedUser ![userId] > DateTime.MinValue),
protected override void ConfigureIocContainer(IServiceCollection services) { base.ConfigureIocContainer(services); _currentUserResolver = Substitute.For <ICurrentUserResolver>(); _currentUserResolver.GetCurrentUserId().Returns(c => _currentUserId); services.AddScoped(x => _currentUserResolver); }
public async Task <ActionResult <CurrentUserResponse> > GetCurrentUser([FromServices] IUserQueryService service, [FromServices] ICurrentUserResolver userResolver) { var currentId = userResolver.GetCurrentUserId(); var userResult = await service.GetById(currentId); return(!userResult.IsSuccess ? userResult.To <CurrentUserResponse>().ToActionResultOfT() : new CurrentUserResponse(userResult.Value, currentId)); }
/// <inheritdoc/> public async Task <UserReference> GetCurrentUserReference() { return((await GetReferenceById(_currentUserResolver.GetCurrentUserId())) !.RemoveEntityPrefixFromId()); }
public Task <UserReference> GetCurrentUserReference() { return(GetReferenceById(_currentUserResolver.GetCurrentUserId()) !); }