public Task <TaskGetPagedListResponse> GetPagedListAsync( TaskGetPagedListRequest request, Dictionary <string, string> headers = default, CancellationToken ct = default) { return(_factory.PostAsync <TaskGetPagedListResponse>( _host + "/Tasks/v1/GetPagedList", null, request, headers, ct)); }
public async Task <ActionResult <TaskGetPagedListResponse> > GetPagedList( TaskGetPagedListRequest request, CancellationToken ct = default) { var response = await _tasksService.GetPagedListAsync(_userContext.AccountId, request, ct); return(ReturnIfAllowed(response, Roles.Tasks, response.Tasks.Select(x => x.AccountId))); }
public async Task WhenGetPagedList_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var attribute = await _create.TaskAttribute.BuildAsync(); var type = await _create.TaskType.BuildAsync(); var status = await _create.TaskStatus.BuildAsync(); var value = "Test".WithGuid(); await Task.WhenAll( _create.Task .WithTypeId(type.Id) .WithStatusId(status.Id) .WithAttributeLink(attribute.Id, value) .BuildAsync(), _create.Task .WithTypeId(type.Id) .WithStatusId(status.Id) .WithAttributeLink(attribute.Id, value) .BuildAsync()); var filterAttributes = new Dictionary <Guid, string> { { attribute.Id, value } }; var filterStatusIds = new List <Guid> { status.Id }; var request = new TaskGetPagedListRequest { AllAttributes = false, Attributes = filterAttributes, StatusIds = filterStatusIds }; var response = await _tasksClient.GetPagedListAsync(request, headers); var results = response.Tasks .Skip(1) .Zip(response.Tasks, (previous, current) => current.CreateDateTime >= previous.CreateDateTime); Assert.NotEmpty(response.Tasks); Assert.All(results, Assert.True); }
public async Task <TaskGetPagedListResponse> GetPagedListAsync( Guid accountId, TaskGetPagedListRequest request, CancellationToken ct) { var tasks = await _storage.Tasks .AsNoTracking() .Include(x => x.Type) .Include(x => x.Status) .Include(x => x.AttributeLinks) .Where(x => x.AccountId == accountId && (request.Name.IsEmpty() || EF.Functions.ILike(x.Name, $"{request.Name}%")) && (request.Description.IsEmpty() || EF.Functions.ILike(x.Description, $"%{request.Description}%")) && (request.Result.IsEmpty() || EF.Functions.ILike(x.Result, $"%{request.Result}%")) && (!request.MinStartDateTime.HasValue || x.StartDateTime >= request.MinStartDateTime) && (!request.MaxStartDateTime.HasValue || x.StartDateTime <= request.MaxStartDateTime) && (!request.MinEndDateTime.HasValue || x.EndDateTime >= request.MinEndDateTime) && (!request.MaxEndDateTime.HasValue || x.EndDateTime <= request.MaxEndDateTime) && (!request.MinDeadLineDateTime.HasValue || x.DeadLineDateTime >= request.MinDeadLineDateTime) && (!request.MaxDeadLineDateTime.HasValue || x.DeadLineDateTime <= request.MaxDeadLineDateTime) && (!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)) .ToListAsync(ct); return(new TaskGetPagedListResponse { TotalCount = tasks .Count(x => x.FilterByAdditional(request)), LastModifyDateTime = tasks .Max(x => x.ModifyDateTime), Tasks = tasks .Where(x => x.FilterByAdditional(request)) .AsQueryable() .SortBy(request.SortBy, request.OrderBy) .Skip(request.Offset) .Take(request.Limit) .ToList() }); }
public static bool FilterByAdditional(this Task task, TaskGetPagedListRequest request) { return((request.TypeIds == null || !request.TypeIds.Any() || request.TypeIds.Any(x => TypeIdsPredicate(task, x))) && (request.StatusIds == null || !request.StatusIds.Any() || request.StatusIds.Any(x => StatusIdsPredicate(task, x))) && (request.CustomerIds == null || !request.CustomerIds.Any() || request.CustomerIds.Any(x => CustomerIdsPredicate(task, x))) && (request.OrderIds == null || !request.OrderIds.Any() || request.OrderIds.Any(x => OrderIdsPredicate(task, x))) && (request.CreateUserIds == null || !request.CreateUserIds.Any() || request.CreateUserIds.Any(x => CreateUserIdsPredicate(task, x))) && (request.ResponsibleUserIds == null || !request.ResponsibleUserIds.Any() || request.ResponsibleUserIds.Any(x => ResponsibleUserIdsPredicate(task, x))) && (request.Attributes == null || !request.Attributes.Any() || (request.AllAttributes is false ? request.Attributes.Any(x => AttributePredicate(task, x)) : request.Attributes.All(x => AttributePredicate(task, x)))) && (request.Priorities == null || !request.Priorities.Any() || request.Priorities.Any(x => PrioritiesPredicate(task, x)))); }