Browse Source

CatalogService: Fix issue with Status set when items list is empty (#1304)

* Fix issue with Status set when items list is empty

* Change method Count() call to Count property

Co-authored-by: Dmytro Hridin <v-dmytro.hridin@lionbridge.com>
pull/1411/head
Dmytro Hridin 4 years ago
committed by GitHub
parent
commit
b426909d36
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions
  1. +5
    -6
      src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs

+ 5
- 6
src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs View File

@ -68,11 +68,10 @@ namespace Catalog.API.Grpc
{
var items = await GetItemsByIdsAsync(request.Ids);
if (!items.Any())
{
context.Status = new Status(StatusCode.NotFound, $"ids value invalid. Must be comma-separated list of numbers");
}
context.Status = new Status(StatusCode.OK, string.Empty);
context.Status = !items.Any() ?
new Status(StatusCode.NotFound, $"ids value invalid. Must be comma-separated list of numbers") :
new Status(StatusCode.OK, string.Empty);
return this.MapToResponse(items);
}
@ -104,7 +103,7 @@ namespace Catalog.API.Grpc
private PaginatedItemsResponse MapToResponse(List<CatalogItem> items)
{
return this.MapToResponse(items, items.Count(), 1, items.Count());
return this.MapToResponse(items, items.Count, 1, items.Count);
}
private PaginatedItemsResponse MapToResponse(List<CatalogItem> items, long count, int pageIndex, int pageSize)


Loading…
Cancel
Save