public async Task WhenGetPagedList_ThenSuccess() { var headers = await _defaultRequestHeadersService.GetAsync(); var status = await _create.OrderStatus.BuildAsync(); status.Name = "Test".WithGuid(); status.IsDeleted = true; await _orderStatusesClient.UpdateAsync(status, headers); var request = new OrderStatusChangeGetPagedListRequest { 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 <OrderStatus>()); Assert.True(!response.Changes.Last().OldValueJson.IsEmpty()); Assert.True(!response.Changes.Last().NewValueJson.IsEmpty()); Assert.False(response.Changes.Last().OldValueJson.FromJsonString <OrderStatus>().IsDeleted); Assert.True(response.Changes.Last().NewValueJson.FromJsonString <OrderStatus>().IsDeleted); Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <OrderStatus>().Name, status.Name); }
public Task <OrderStatusChangeGetPagedListResponse> GetPagedListAsync( OrderStatusChangeGetPagedListRequest request, Dictionary <string, string> headers = default, CancellationToken ct = default) { return(_factory.PostAsync <OrderStatusChangeGetPagedListResponse>( _host + "/Orders/Statuses/Changes/v1/GetPagedList", null, request, headers, ct)); }
public async Task <ActionResult <OrderStatusChangeGetPagedListResponse> > GetPagedList( OrderStatusChangeGetPagedListRequest request, CancellationToken ct = default) { var status = await _orderStatusesService.GetAsync(request.StatusId, false, ct); var response = await _orderStatusChangesService.GetPagedListAsync(request, ct); return(ReturnIfAllowed(response, Roles.Orders, status.AccountId)); }
public async Task <OrderStatusChangeGetPagedListResponse> GetPagedListAsync( OrderStatusChangeGetPagedListRequest request, CancellationToken ct) { var changes = _storage.OrderStatusChanges .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 OrderStatusChangeGetPagedListResponse { TotalCount = await changes .CountAsync(ct), Changes = await changes .SortBy(request.SortBy, request.OrderBy) .Skip(request.Offset) .Take(request.Limit) .ToListAsync(ct) }); }