Skip to content

Commit b426909

Browse files
dmytrohridinDmytro Hridin
andauthored
CatalogService: Fix issue with Status set when items list is empty (dotnet-architecture#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>
1 parent 7dad5c0 commit b426909

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ public override async Task<PaginatedItemsResponse> GetItemsByIds(CatalogItemsReq
6868
{
6969
var items = await GetItemsByIdsAsync(request.Ids);
7070

71-
if (!items.Any())
72-
{
73-
context.Status = new Status(StatusCode.NotFound, $"ids value invalid. Must be comma-separated list of numbers");
74-
}
75-
context.Status = new Status(StatusCode.OK, string.Empty);
71+
context.Status = !items.Any() ?
72+
new Status(StatusCode.NotFound, $"ids value invalid. Must be comma-separated list of numbers") :
73+
new Status(StatusCode.OK, string.Empty);
74+
7675
return this.MapToResponse(items);
7776
}
7877

@@ -104,7 +103,7 @@ public override async Task<PaginatedItemsResponse> GetItemsByIds(CatalogItemsReq
104103

105104
private PaginatedItemsResponse MapToResponse(List<CatalogItem> items)
106105
{
107-
return this.MapToResponse(items, items.Count(), 1, items.Count());
106+
return this.MapToResponse(items, items.Count, 1, items.Count);
108107
}
109108

110109
private PaginatedItemsResponse MapToResponse(List<CatalogItem> items, long count, int pageIndex, int pageSize)

0 commit comments

Comments
 (0)