diff --git a/blazor_lab/Components/InventoryItem.razor b/blazor_lab/Components/InventoryItem.razor
index 789ca64..e19e94d 100644
--- a/blazor_lab/Components/InventoryItem.razor
+++ b/blazor_lab/Components/InventoryItem.razor
@@ -13,7 +13,10 @@
@if (InventoryModel is not null && IsInInventory)
{
-

+ @if (InventoryModel.NumberItem > 0)
+ {
+
@InventoryModel.ItemName
+ }
@InventoryModel.NumberItem
}
diff --git a/blazor_lab/Components/InventoryItem.razor.cs b/blazor_lab/Components/InventoryItem.razor.cs
index 6eb88a0..1d26a07 100644
--- a/blazor_lab/Components/InventoryItem.razor.cs
+++ b/blazor_lab/Components/InventoryItem.razor.cs
@@ -1,6 +1,7 @@
using blazor_lab.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
+using Minecraft.Crafting.Api;
using Minecraft.Crafting.Api.Models;
using System.Diagnostics;
using Item = blazor_lab.Models.Item;
@@ -27,9 +28,6 @@ namespace blazor_lab.Components
[CascadingParameter]
public Inventory? InventoryParent { get; set; }
- [Inject]
- public IDataService DataService { get; set; }
-
public InventoryModel InventoryModel { get; set; } = new InventoryModel();
public InventoryItem()
@@ -54,7 +52,7 @@ namespace blazor_lab.Components
{
InventoryModel = InventoryParent!.CurrentDragItem!;
InventoryModel.Position = Position;
- InventoryParent.InventoryContent.Add(InventoryModel);
+ InventoryParent.InventoryContent.Insert(Position, InventoryModel);
}
else
{
@@ -64,6 +62,7 @@ namespace blazor_lab.Components
}
}
}
+ StateHasChanged();
}
internal void OnDragEnd()
@@ -92,18 +91,5 @@ namespace blazor_lab.Components
}
}
}
-
- public async Task GetItemImageBase64()
- {
- // FIXME probably not great to inject a service in each item and query the whole database everytime we display it
-
- if (InventoryParent is not null)
- {
- return (await DataService.List(0, await DataService.Count()))
- .FirstOrDefault(i => i.DisplayName == InventoryModel.ItemName)?
- .ImageBase64;
- }
- else return null;
- }
}
}