From fce7734df61b66e7e8b41509a99f00cae41f6535 Mon Sep 17 00:00:00 2001 From: James Chapman Date: Sun, 12 Nov 2023 19:34:06 +0000 Subject: [PATCH] Return newest item when scanning barcode linked to multiple items --- Groceries/Transactions/TransactionsController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Groceries/Transactions/TransactionsController.cs b/Groceries/Transactions/TransactionsController.cs index 5389cf1..2521e43 100644 --- a/Groceries/Transactions/TransactionsController.cs +++ b/Groceries/Transactions/TransactionsController.cs @@ -111,6 +111,7 @@ public class TransactionsController : Controller { var item = await dbContext.Items .Where(item => item.Barcodes.Any(barcode => barcode.BarcodeData == barcodeData)) + .OrderByDescending(item => item.UpdatedAt) .FirstOrDefaultAsync(); item ??= new Item(id: default);