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:
parent
609ced26f3
commit
eaa104659d
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
|
|
@ -107,19 +107,22 @@
|
|||
private async Task ReloadDataFromDb(bool forceReload = false)
|
||||
{
|
||||
LoadingPanelVisibility.Visible = true;
|
||||
using (await ObjectLock.GetSemaphore<OrderDto>().UseWaitAsync())
|
||||
|
||||
if (IsMasterGrid)
|
||||
{
|
||||
if (OrderDtos == null) OrderDtos = await FruitBankSignalRClient.GetAllOrderDtos() ?? [];
|
||||
else if (OrderDtos.Count == 0 || forceReload)
|
||||
using (await ObjectLock.GetSemaphore<OrderDto>().UseWaitAsync())
|
||||
{
|
||||
OrderDtos.Clear();
|
||||
OrderDtos.AddRange(await FruitBankSignalRClient.GetAllOrderDtos() ?? []);
|
||||
if (OrderDtos == null) OrderDtos = await FruitBankSignalRClient.GetAllOrderDtos() ?? [];
|
||||
else if (OrderDtos.Count == 0 || forceReload)
|
||||
{
|
||||
OrderDtos.Clear();
|
||||
OrderDtos.AddRange(await FruitBankSignalRClient.GetAllOrderDtos() ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
//if (forceReload)
|
||||
Grid?.Reload();
|
||||
}
|
||||
|
||||
//if (forceReload)
|
||||
Grid?.Reload();
|
||||
|
||||
LoadingPanelVisibility.Visible = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue