Set default ShippingDate, refactor data reload logic

Set default ShippingDate to DateTime.Now in Shipping and ShippingDocument entities. Refactored data reload logic in GridDetailOrderDto.razor to use semaphore only for master grid and moved grid reload accordingly. Updated GridProductDtoTemplate.razor to load order data on tab change instead of detail row expansion.
This commit is contained in:
Loretta 2026-01-06 10:41:27 +01:00
parent 609ced26f3
commit eaa104659d
4 changed files with 22 additions and 19 deletions

View File

@ -8,7 +8,7 @@ namespace FruitBank.Common.Entities;
[System.ComponentModel.DataAnnotations.Schema.Table(FruitBankConstClient.ShippingDbTableName)]
public class Shipping : MgEntityBase, IShipping
{
public DateTime ShippingDate { get; set; }
public DateTime ShippingDate { get; set; } = DateTime.Now;
public string LicencePlate { get; set; }
public bool IsAllMeasured { get; set; }

View File

@ -14,7 +14,7 @@ public class ShippingDocument : MgEntityBase, IShippingDocument
public string DocumentIdNumber { get; set; }
public string PdfFileName { get; set; }
public DateTime ShippingDate { get; set; }
public DateTime ShippingDate { get; set; } = DateTime.Now;
public string Country { get; set; }
public int TotalPallets { get; set; }

View File

@ -107,6 +107,9 @@
private async Task ReloadDataFromDb(bool forceReload = false)
{
LoadingPanelVisibility.Visible = true;
if (IsMasterGrid)
{
using (await ObjectLock.GetSemaphore<OrderDto>().UseWaitAsync())
{
if (OrderDtos == null) OrderDtos = await FruitBankSignalRClient.GetAllOrderDtos() ?? [];
@ -119,7 +122,7 @@
//if (forceReload)
Grid?.Reload();
}
LoadingPanelVisibility.Visible = false;
}

View File

@ -179,11 +179,11 @@
var productDto = (ProductDto)e.DataItem;
if (e.Grid.IsDetailRowExpanded(e.VisibleIndex))
{
_currentOrderDtos = null;
_currentOrderDtos = productDto != null ? await GetOrderDtosFromDbAsync(productDto.Id) : [];
}
// if (e.Grid.IsDetailRowExpanded(e.VisibleIndex))
// {
// _currentOrderDtos = null;
// _currentOrderDtos = productDto != null ? await GetOrderDtosFromDbAsync(productDto.Id) : [];
// }
}
protected async Task OnActiveTabChanged(int activeTabIndex, int productId)
@ -192,11 +192,11 @@
switch (_activeTabIndex)
{
case 0:
//_currentOrderDtos = null;
case 1:
_currentOrderDtos = null;
_currentOrderDtos = await GetOrderDtosFromDbAsync(productId);
break;
case 1:
case 2:
_currentOrderItemDtos = null;
_currentOrderItemDtos = await GetOrderItemDtosFromDbAsync(productId);
break;