public async Task WhenGetPagedList_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var status = await _create.TaskStatus.BuildAsync(); status.Name = "Test".WithGuid(); status.IsDeleted = true; await _taskStatusesClient.UpdateAsync(status, headers); var request = new TaskStatusChangeGetPagedListRequest { StatusId = status.Id, SortBy = "CreateDateTime", OrderBy = "asc" }; var response = await _statusChangesClient.GetPagedListAsync(request, headers); Assert.NotEmpty(response.Changes); Assert.True(response.Changes.All(x => !x.ChangerUserId.IsEmpty())); Assert.True(response.Changes.All(x => x.StatusId == status.Id)); Assert.True(response.Changes.All(x => x.CreateDateTime.IsMoreThanMinValue())); Assert.True(response.Changes.First().OldValueJson.IsEmpty()); Assert.True(!response.Changes.First().NewValueJson.IsEmpty()); Assert.NotNull(response.Changes.First().NewValueJson.FromJsonString <CrmTaskStatus>()); Assert.True(!response.Changes.Last().OldValueJson.IsEmpty()); Assert.True(!response.Changes.Last().NewValueJson.IsEmpty()); Assert.False(response.Changes.Last().OldValueJson.FromJsonString <CrmTaskStatus>().IsDeleted); Assert.True(response.Changes.Last().NewValueJson.FromJsonString <CrmTaskStatus>().IsDeleted); Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <CrmTaskStatus>().Name, status.Name); }
public Task <TaskStatusChangeGetPagedListResponse> GetPagedListAsync( TaskStatusChangeGetPagedListRequest request, Dictionary <string, string> headers = default, CancellationToken ct = default) { return(_factory.PostAsync <TaskStatusChangeGetPagedListResponse>( _host + "/Tasks/Statuses/Changes/v1/GetPagedList", null, request, headers, ct)); }
public async Task <ActionResult <TaskStatusChangeGetPagedListResponse> > GetPagedList( TaskStatusChangeGetPagedListRequest request, CancellationToken ct = default) { var status = await _taskStatusesService.GetAsync(request.StatusId, false, ct); var response = await _taskStatusChangesService.GetPagedListAsync(request, ct); return(ReturnIfAllowed(response, Roles.Tasks, status.AccountId)); }
public async Task <TaskStatusChangeGetPagedListResponse> GetPagedListAsync( TaskStatusChangeGetPagedListRequest request, CancellationToken ct) { var changes = _storage.TaskStatusChanges .AsNoTracking() .Where(x => (request.StatusId.IsEmpty() || x.StatusId == request.StatusId) && (!request.MinCreateDate.HasValue || x.CreateDateTime >= request.MinCreateDate) && (!request.MaxCreateDate.HasValue || x.CreateDateTime <= request.MaxCreateDate)); return(new TaskStatusChangeGetPagedListResponse { TotalCount = await changes .CountAsync(ct), Changes = await changes .SortBy(request.SortBy, request.OrderBy) .Skip(request.Offset) .Take(request.Limit) .ToListAsync(ct) }); }