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.
This commit is contained in:
Loretta 2026-03-04 15:22:51 +01:00
parent 288b81f8f5
commit f5915f7f72
5 changed files with 45 additions and 27 deletions

View File

@ -41,7 +41,7 @@
<HintPath>..\..\..\..\Aycode\Source\AyCode.Core\AyCode.Services.Server\bin\FruitBank\Debug\net9.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.SignalR.Core">
<HintPath>C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.12\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
<HintPath>C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\9.0.13\ref\net9.0\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
</Reference>
<Reference Include="Mango.Nop.Core">
<HintPath>..\..\NopCommerce.Common\4.70\Libraries\Mango.Nop.Core\bin\FruitBank\Debug\net9.0\Mango.Nop.Core.dll</HintPath>

View File

@ -8,6 +8,7 @@ public interface IStockSignalREndpointCommon
public Task<List<StockTaking>?> GetStockTakings(bool loadRelations);
public Task<List<StockTaking>?> GetStockTakingsByProductId(int productId);
public Task<StockTaking?> AddStockTaking(StockTaking stockTaking);
public Task<StockTakingItem?> RefreshStockTakingItem(int stockTakingItemId);
public Task<StockTaking?> UpdateStockTaking(StockTaking stockTaking);
public Task<List<StockTakingItem>?> GetStockTakingItems();

View File

@ -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;

View File

@ -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))">
</DxComboBox>
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="4">
@ -73,8 +73,15 @@
<div>
@{
var a = $"Várható rekesz: {SelectedStockTakingItem.TotalOriginalQuantity} ({SelectedStockTakingItem.OriginalStockQuantity} + {SelectedStockTakingItem.InProcessOrdersQuantity}), Várható net.súly: {SelectedStockTakingItem.OriginalNetWeight} kg.";
<span>@a</span>
<span>@a</span>
}
@if (SelectedStockTakingItem.IsInvalid)
{
<div class="text-danger" style="margin-top: 15px">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.</div>
<DxButton Text="Frissítés" Click="() => RefreshErrorItemClick(SelectedStockTakingItem)"></DxButton>
}
</div>
<DxFormLayout Data="@SelectedStockTakingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" Enabled="@((!SelectedStockTaking?.IsClosed ?? false))">
<DxFormLayoutItem Context="ctxShippingItemFromLayoutItem" ColSpanMd="12">
@ -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);
}

View File

@ -292,6 +292,7 @@ namespace FruitBankHybrid.Shared.Services.SignalRs
}
public Task<StockTaking?> AddStockTaking(StockTaking stockTaking) => PostDataAsync(SignalRTags.AddStockTaking, stockTaking);
public Task<StockTakingItem?> RefreshStockTakingItem(int stockTakingItemId) => GetByIdAsync<StockTakingItem>(SignalRTags.RefreshStockTakingItem, stockTakingItemId);
public Task<StockTaking?> UpdateStockTaking(StockTaking stockTaking) => PostDataAsync(SignalRTags.UpdateStockTaking, stockTaking);