using BlazorApp1.Modals; using BlazorApp1.Sevices; using Blazored.LocalStorage; using Blazored.Modal; using Blazored.Modal.Services; using Blazorise.DataGrid; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; namespace BlazorApp1.Components { public partial class Inventory { [Parameter] public List Items { get; set; } public Item CurrentDragItem { get; set; } public ItemDisplay CurrentEllement { get; set; } [Inject] public ILocalStorageService LocalStorage { get; set; } public List InventoryItems { get; set; } = new List() { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; public List InventoryNbElems { get; set; } = new List() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; public int CurrenttmpNbElem { get; set; } public void StateChange() { StateHasChanged(); LocalStorage.SetItemAsync("dataInv", InventoryItems); LocalStorage.SetItemAsync("dataNbInv", InventoryNbElems); } protected override async Task OnInitializedAsync() { try { var currentNumberData = await LocalStorage.GetItemAsync>("dataNbInv"); var currentData = await LocalStorage.GetItemAsync>("dataInv"); if (currentData != null) { InventoryItems = await LocalStorage.GetItemAsync>("dataInv"); } if (currentNumberData != null ) { InventoryNbElems = await LocalStorage.GetItemAsync>("dataNbInv"); } } catch (Exception) { throw; } StateHasChanged(); } public Item getItem(String name) { int indice = 0; foreach (Item i in Items) { if (i.Name == name) { return Items[indice]; } indice++; } return null; } public String getNameCurrentItem() { if (CurrentDragItem != null) { return CurrentDragItem.Name; } return null; } } }