コード例 #1
0
        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),
コード例 #2
0
        protected override void ConfigureIocContainer(IServiceCollection services)
        {
            base.ConfigureIocContainer(services);

            _currentUserResolver = Substitute.For <ICurrentUserResolver>();
            _currentUserResolver.GetCurrentUserId().Returns(c => _currentUserId);
            services.AddScoped(x => _currentUserResolver);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 /// <inheritdoc/>
 public async Task <UserReference> GetCurrentUserReference()
 {
     return((await GetReferenceById(_currentUserResolver.GetCurrentUserId())) !.RemoveEntityPrefixFromId());
 }
コード例 #5
0
 public Task <UserReference> GetCurrentUserReference()
 {
     return(GetReferenceById(_currentUserResolver.GetCurrentUserId()) !);
 }