From f5915f7f723354ed7fefe11582f82145af6c9e8d Mon Sep 17 00:00:00 2001 From: Loretta Date: Wed, 4 Mar 2026 15:22:51 +0100 Subject: [PATCH] Add RefreshStockTakingItem support and UI error handling Updated SignalR interface and tags to support refreshing individual StockTakingItems. Improved StockTakingTemplate.razor to show error messages and allow item refresh when invalid. Removed unused method and updated project reference to SignalR.Core 9.0.13. --- .../FruitBank.Common.Server.csproj | 2 +- .../Interfaces/IStockSignalREndpointCommon.cs | 1 + FruitBank.Common/SignalRs/SignalRTags.cs | 15 +++--- .../StockTakings/StockTakingTemplate.razor | 53 ++++++++++++------- .../SignalRs/FruitBankSignalRClient.cs | 1 + 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/FruitBank.Common.Server/FruitBank.Common.Server.csproj b/FruitBank.Common.Server/FruitBank.Common.Server.csproj index 2cc380da..c31b4f30 100644 --- a/FruitBank.Common.Server/FruitBank.Common.Server.csproj +++ b/FruitBank.Common.Server/FruitBank.Common.Server.csproj @@ -41,7 +41,7 @@ ..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll - C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.12\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll + C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.13\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll ..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll diff --git a/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs b/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs index e943579d..2ec4d4ac 100644 --- a/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs +++ b/FruitBank.Common/Interfaces/IStockSignalREndpointCommon.cs @@ -8,6 +8,7 @@ public interface IStockSignalREndpointCommon public Task?> GetStockTakings(bool loadRelations); public Task?> GetStockTakingsByProductId(int productId); public Task AddStockTaking(StockTaking stockTaking); + public Task RefreshStockTakingItem(int stockTakingItemId); public Task UpdateStockTaking(StockTaking stockTaking); public Task?> GetStockTakingItems(); diff --git a/FruitBank.Common/SignalRs/SignalRTags.cs b/FruitBank.Common/SignalRs/SignalRTags.cs index 30d07302..13f0471f 100644 --- a/FruitBank.Common/SignalRs/SignalRTags.cs +++ b/FruitBank.Common/SignalRs/SignalRTags.cs @@ -92,13 +92,14 @@ public class SignalRTags : AcSignalRTags public const int GetStockTakings = 170; public const int AddStockTaking = 171; - public const int UpdateStockTaking = 172; - public const int CloseStockTaking = 173; - public const int GetStockTakingItems = 174; - public const int GetStockTakingItemsById = 175; - public const int GetStockTakingItemsByProductId = 176; - public const int GetStockTakingItemsByStockTakingId = 177; - public const int AddOrUpdateMeasuredStockTakingItemPallet = 178; + public const int RefreshStockTakingItem = 172; + public const int UpdateStockTaking = 173; + public const int CloseStockTaking = 174; + public const int GetStockTakingItems = 175; + public const int GetStockTakingItemsById = 176; + public const int GetStockTakingItemsByProductId = 177; + public const int GetStockTakingItemsByStockTakingId = 178; + public const int AddOrUpdateMeasuredStockTakingItemPallet = 179; public const int AuthenticateUser = 195; diff --git a/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor b/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor index 92504c87..d4b7f485 100644 --- a/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor +++ b/FruitBankHybrid.Shared/Components/StockTakings/StockTakingTemplate.razor @@ -31,7 +31,7 @@ Context="ctxProduct" InputId="cbProduct" Value="@SelectedStockTaking" - ValueChanged="@(async (StockTaking stockTaking) => await StockTakingComboValueChanged(stockTaking))"> + ValueChanged="@(async (StockTaking stockTaking) => await StockTakingComboValueChanged(stockTaking, null))"> @@ -73,8 +73,15 @@
@{ var a = $"Várható rekesz: {SelectedStockTakingItem.TotalOriginalQuantity} ({SelectedStockTakingItem.OriginalStockQuantity} + {SelectedStockTakingItem.InProcessOrdersQuantity}), Várható net.súly: {SelectedStockTakingItem.OriginalNetWeight} kg."; - @a + @a } + + @if (SelectedStockTakingItem.IsInvalid) + { +
A várható mennyiség nem lehet negatív! A hibás adatok javítása után nyomja meg a "Frissítés" gombot.
+ + } +
@@ -141,11 +148,26 @@ LoadingPanelVisible = true; _stockTakings = await FruitBankSignalRClient.GetStockTakings(false) ?? []; - await StockTakingComboValueChanged(_stockTakings.FirstOrDefault()); + await StockTakingComboValueChanged(_stockTakings.FirstOrDefault(), null); LoadingPanelVisible = false; } + private async Task RefreshErrorItemClick(StockTakingItem errorTakingItem) + { + var stockTakingItem = await FruitBankSignalRClient.RefreshStockTakingItem(errorTakingItem.Id); + if (stockTakingItem == null) + { + await DialogService.ShowMessageBoxAsync("Hiba", "Adatok frissése sikertelen volt!", MessageBoxRenderStyle.Danger); + return; + } + + await StockTakingComboValueChanged(SelectedStockTaking, stockTakingItem.Id); + + if (stockTakingItem.IsInvalid) + await DialogService.ShowMessageBoxAsync("Figyelem", "A termék továbbra is hibás!", MessageBoxRenderStyle.Warning); + } + private async Task NewStockTakingClick() { _btnDisabled = true; @@ -154,9 +176,11 @@ { LoadingPanelVisible = true; - var stockTaking = new StockTaking(); - stockTaking.StartDateTime = DateTime.Now; - stockTaking.Creator = LoggedInModel.CustomerDto!.Id; + var stockTaking = new StockTaking + { + StartDateTime = DateTime.Now, + Creator = LoggedInModel.CustomerDto!.Id + }; var resultStockTakings = await FruitBankSignalRClient.AddStockTaking(stockTaking); if (resultStockTakings == null) @@ -166,7 +190,7 @@ } _stockTakings.UpdateCollection(resultStockTakings, false); - await StockTakingComboValueChanged(_stockTakings.FirstOrDefault(x => x.Id == resultStockTakings.Id)); + await StockTakingComboValueChanged(_stockTakings.FirstOrDefault(x => x.Id == resultStockTakings.Id), null); } finally { @@ -178,15 +202,6 @@ await InvokeAsync(StateHasChanged); } - private async Task UpdateStockTakingClick() - { - // var resultStockTaking = await FruitBankSignalRClient.AddStockTaking(stockTaking); - // if (resultStockTaking == null) return; - - // _stockTakings.Add(resultStockTaking); - await InvokeAsync(StateHasChanged); - } - private async Task StockTakingCloseClick(int stockTakingId) { _btnDisabled = true; @@ -203,7 +218,7 @@ } _stockTakings.UpdateCollection(resultStockTaking, false); - await StockTakingComboValueChanged(_stockTakings.FirstOrDefault(x => x.Id == resultStockTaking.Id)); + await StockTakingComboValueChanged(_stockTakings.FirstOrDefault(x => x.Id == resultStockTaking.Id), null); } finally { @@ -214,14 +229,14 @@ await InvokeAsync(StateHasChanged); } - private async Task StockTakingComboValueChanged(StockTaking? newValue) + private async Task StockTakingComboValueChanged(StockTaking? newValue, int? selectedStockTakingItemId) { SelectedStockTaking = newValue; SelectedStockTaking?.StockTakingItems = await FruitBankSignalRClient.GetStockTakingItemsByStockTakingId(SelectedStockTaking.Id); PrepareStockTakingItems(SelectedStockTaking); - SelectedStockTakingItem = _stockTakingItems.FirstOrDefault(); + SelectedStockTakingItem = selectedStockTakingItemId.HasValue ? _stockTakingItems.FirstOrDefault(x => x.Id == selectedStockTakingItemId.Value) : _stockTakingItems.FirstOrDefault(); await InvokeAsync(StateHasChanged); } diff --git a/FruitBankHybrid.Shared/Services/SignalRs/FruitBankSignalRClient.cs b/FruitBankHybrid.Shared/Services/SignalRs/FruitBankSignalRClient.cs index 8b8bc8e7..6f5ea823 100644 --- a/FruitBankHybrid.Shared/Services/SignalRs/FruitBankSignalRClient.cs +++ b/FruitBankHybrid.Shared/Services/SignalRs/FruitBankSignalRClient.cs @@ -292,6 +292,7 @@ namespace FruitBankHybrid.Shared.Services.SignalRs } public Task AddStockTaking(StockTaking stockTaking) => PostDataAsync(SignalRTags.AddStockTaking, stockTaking); + public Task RefreshStockTakingItem(int stockTakingItemId) => GetByIdAsync(SignalRTags.RefreshStockTakingItem, stockTakingItemId); public Task UpdateStockTaking(StockTaking stockTaking) => PostDataAsync(SignalRTags.UpdateStockTaking, stockTaking);