Пример #1
0
        public async Task <TaskAttributeGetPagedListResponse> GetPagedListAsync(
            Guid accountId,
            TaskAttributeGetPagedListRequest request,
            CancellationToken ct)
        {
            var attributes = _storage.TaskAttributes
                             .AsNoTracking()
                             .Where(x =>
                                    x.AccountId == accountId &&
                                    (request.Types == null || !request.Types.Any() || request.Types.Contains(x.Type)) &&
                                    (request.Key.IsEmpty() || EF.Functions.ILike(x.Key, $"{request.Key}%")) &&
                                    (!request.IsDeleted.HasValue || x.IsDeleted == request.IsDeleted) &&
                                    (!request.MinCreateDate.HasValue || x.CreateDateTime >= request.MinCreateDate) &&
                                    (!request.MaxCreateDate.HasValue || x.CreateDateTime <= request.MaxCreateDate) &&
                                    (!request.MinModifyDate.HasValue || x.ModifyDateTime >= request.MinModifyDate) &&
                                    (!request.MaxModifyDate.HasValue || x.ModifyDateTime <= request.MaxModifyDate));

            return(new TaskAttributeGetPagedListResponse
            {
                TotalCount = await attributes
                             .CountAsync(ct),
                LastModifyDateTime = await attributes
                                     .MaxAsync(x => x != null?x.ModifyDateTime ?? x.CreateDateTime : (DateTime?)null, ct),
                Attributes = await attributes
                             .SortBy(request.SortBy, request.OrderBy)
                             .Skip(request.Offset)
                             .Take(request.Limit)
                             .ToListAsync(ct)
            });
        }
Пример #2
0
        public async Task WhenGetPagedList_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var key = "Test".WithGuid();

            await Task.WhenAll(
                _create.TaskAttribute
                .WithType(AttributeType.Text)
                .WithKey(key)
                .BuildAsync());

            var filterTypes = new List <AttributeType> {
                AttributeType.Text
            };

            var request = new TaskAttributeGetPagedListRequest
            {
                Key   = key,
                Types = filterTypes
            };

            var response = await _taskAttributesClient.GetPagedListAsync(request, headers);

            var results = response.Attributes
                          .Skip(1)
                          .Zip(response.Attributes, (previous, current) => current.CreateDateTime >= previous.CreateDateTime);

            Assert.NotEmpty(response.Attributes);
            Assert.All(results, Assert.True);
        }
Пример #3
0
        public async Task <ActionResult <TaskAttributeGetPagedListResponse> > GetPagedList(
            TaskAttributeGetPagedListRequest request,
            CancellationToken ct = default)
        {
            var response = await _taskAttributesService.GetPagedListAsync(_userContext.AccountId, request, ct);

            return(ReturnIfAllowed(response, Roles.Tasks, response.Attributes.Select(x => x.AccountId)));
        }
Пример #4
0
 public Task <TaskAttributeGetPagedListResponse> GetPagedListAsync(
     TaskAttributeGetPagedListRequest request,
     Dictionary <string, string> headers = default,
     CancellationToken ct = default)
 {
     return(_factory.PostAsync <TaskAttributeGetPagedListResponse>(
                _host + "/Tasks/Attributes/v1/GetPagedList", null, request, headers, ct));
 }