|
|
@ -31,8 +31,8 @@ namespace Blazor.Components
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public async void update()
|
|
|
|
public async void update()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await LocalStorage.SetItemAsync("list", inventory);
|
|
|
|
|
|
|
|
this.StateHasChanged();
|
|
|
|
this.StateHasChanged();
|
|
|
|
|
|
|
|
await LocalStorage.SetItemAsync("list", inventory.inventoryItems);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -43,24 +43,7 @@ namespace Blazor.Components
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
|
|
|
|
// Do not treat this action if is not the first render
|
|
|
|
|
|
|
|
if (!firstRender)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Item[]>("data");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if data exist in the local storage
|
|
|
|
|
|
|
|
if (currentData == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// this code add in the local storage the fake data (we load the data sync for initialize the data before load the OnReadData method)
|
|
|
|
|
|
|
|
await LocalStorage.SetItemAsync("list", inventory);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
@ -68,13 +51,13 @@ namespace Blazor.Components
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var response = (await LocalStorage.GetItemAsync<Models.InventoryList>("list"));
|
|
|
|
var response = (await LocalStorage.GetItemAsync<List<InventoryItem>>("list"));
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
inventory = response;
|
|
|
|
inventory.inventoryItems = response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|