diff --git a/Sources/BlazorT/Composants/Crafting.razor b/Sources/BlazorT/Composants/Crafting.razor
index 36c1224..f415836 100644
--- a/Sources/BlazorT/Composants/Crafting.razor
+++ b/Sources/BlazorT/Composants/Crafting.razor
@@ -6,20 +6,13 @@
Available items:
-
+
@foreach (var item in Items)
{
-
-
- {item}
- |
-
+
- |
-
-
- }
-
+
+ }
diff --git a/Sources/BlazorT/Composants/InventoryItemTR.razor.cs b/Sources/BlazorT/Composants/InventoryItemTR.razor.cs
index 0711354..14470e4 100644
--- a/Sources/BlazorT/Composants/InventoryItemTR.razor.cs
+++ b/Sources/BlazorT/Composants/InventoryItemTR.razor.cs
@@ -33,7 +33,10 @@ namespace BlazorT.Composants
[Inject]
public NavigationManager NavigationManager { get; set; }
-
+ ///
+ /// Gère l'événement de glisser-déposer lorsqu'un élément est glissé sur la case.
+ /// Ajoute une action d'inventaire pour enregistrer l'événement.
+ ///
internal void OnDragEnter()
{
if (NoDrop)
@@ -45,6 +48,10 @@ namespace BlazorT.Composants
Parent.Actions.Add(new InventoryAction { Action = "Drag Enter", Item = this.Item, Index = this.Index });
}
+ ///
+ /// Gère l'événement de glisser-déposer lorsqu'un élément est glissé hors de la case.
+ /// Ajoute une action d'inventaire pour enregistrer l'événement.
+ ///
internal void OnDragLeave()
{
if (NoDrop)
@@ -57,6 +64,10 @@ namespace BlazorT.Composants
Parent.Actions.Add(new InventoryAction { Action = "Drag Leave", Item = this.Item, Index = this.Index });
}
+ ///
+ /// Gère l'événement de glisser-déposer lorsqu'un élément est déposé sur la case.
+ /// Ajoute une action d'inventaire pour enregistrer l'événement, met à jour l'élément de la case et vérifie si une recette est possible.
+ ///
internal void OnDrop()
{
if (NoDrop)
@@ -77,6 +88,10 @@ namespace BlazorT.Composants
Parent.CheckRecipe();
}
+ ///
+ /// Gère l'événement de glisser-déposer lorsqu'un élément est déplacé.
+ /// Ajoute une action d'inventaire pour enregistrer l'événement.
+ ///
private void OnDragStart()
{
Parent.CurrentDragItem = this.Item;
@@ -85,7 +100,12 @@ namespace BlazorT.Composants
Parent.Actions.Add(new InventoryAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
}
-
+ ///
+ /// Gère l'événement de suppression d'un élément.
+ /// Affiche une fenêtre modale de confirmation et supprime l'élément s'il est confirmé.
+ /// Ajoute une action d'inventaire pour enregistrer l'événement et recharge la page.
+ ///
+ /// ID de l'élément à supprimer
private async Task OnDeleteAsync(int id)
{
var parameters = new ModalParameters();
@@ -106,6 +126,6 @@ namespace BlazorT.Composants
NavigationManager.NavigateTo("inventory", true);
}
+
}
}
-
diff --git a/Sources/BlazorT/Pages/Inventory.razor.cs b/Sources/BlazorT/Pages/Inventory.razor.cs
index 384967e..94f4ba2 100644
--- a/Sources/BlazorT/Pages/Inventory.razor.cs
+++ b/Sources/BlazorT/Pages/Inventory.razor.cs
@@ -20,12 +20,12 @@ public partial class Inventory
[Inject]
public IConfiguration Configuration { set; get; }
- ///
- /// une méthode asynchrone de cycle de vie appelée OnAfterRenderAsync, qui est exécutée après le rendu initial de la page ou du composant.
- /// La méthode commence par appeler la version de la méthode de cycle de vie parente avec l'instruction base.OnAfterRenderAsync (firstRender)
-
- ///
-
+ ///
+ /// Method that is invoked after the component has been rendered.
+ ///
+ /// Boolean indicating if this is the first time the component is being rendered.
+ /// A Task representing the asynchronous operation.
+
protected override async Task OnAfterRenderAsync(bool firstRender)
{
base.OnAfterRenderAsync(firstRender);
diff --git a/Sources/BlazorT/Services/IInventoryDataService.cs b/Sources/BlazorT/Services/IInventoryDataService.cs
index 5967f03..2c616fd 100644
--- a/Sources/BlazorT/Services/IInventoryDataService.cs
+++ b/Sources/BlazorT/Services/IInventoryDataService.cs
@@ -4,19 +4,51 @@ using BlazorT.Models;
namespace BlazorT.Services
{
public interface IInventoryDataService
- {
- Task Add(ItemModel model);
-
- Task Count();
-
- Task> List(int currentPage, int pageSize);
+ {
+ ///
+ /// Ajoute un élément à l'inventaire.
+ ///
+ /// Modèle de l'élément à ajouter.
+ public Task Add(ItemModel model);
- Task- GetById(int id);
+ ///
+ /// Récupère le nombre total d'éléments dans l'inventaire.
+ ///
+ /// Le nombre total d'éléments dans l'inventaire.
+ public Task Count();
- Task Update(int id, ItemModel model);
+ ///
+ /// Récupère une liste d'éléments de l'inventaire.
+ ///
+ /// La page courante de la liste.
+ /// Le nombre d'éléments par page.
+ /// Une liste d'éléments de l'inventaire.
+ public Task
> List(int currentPage, int pageSize);
- Task Delete(int id);
-
- Task> GetRecipes();
+ ///
+ /// Récupère un élément de l'inventaire par ID.
+ ///
+ /// ID de l'élément à récupérer.
+ /// L'élément de l'inventaire correspondant à l'ID spécifié.
+ public Task- GetById(int id);
+
+ ///
+ /// Met à jour un élément de l'inventaire.
+ ///
+ /// ID de l'élément à mettre à jour.
+ /// Modèle de l'élément à mettre à jour.
+ public Task Update(int id, ItemModel model);
+
+ ///
+ /// Supprime un élément de l'inventaire.
+ ///
+ /// ID de l'élément à supprimer.
+ public Task Delete(int id);
+
+ ///
+ /// Récupère une liste de recettes d'artisanat.
+ ///
+ /// Une liste de recettes d'artisanat.
+ public Task
> GetRecipes();
}
}
\ No newline at end of file
diff --git a/Sources/BlazorT/Services/InventoryDataService.cs b/Sources/BlazorT/Services/InventoryDataService.cs
index b830d11..e9f981d 100644
--- a/Sources/BlazorT/Services/InventoryDataService.cs
+++ b/Sources/BlazorT/Services/InventoryDataService.cs
@@ -8,13 +8,23 @@ public class InventoryDataService : IInventoryDataService
{
private readonly HttpClient _http;
private ILogger _logger;
- public InventoryDataService(
- HttpClient http,ILogger logger )
+
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HttpClient used for HTTP requests.
+ /// The ILogger used for logging.
+ public InventoryDataService(HttpClient http, ILogger logger)
{
- _logger = logger;
_http = http;
+ _logger = logger;
}
+ ///
+ /// Adds a new item to the inventory.
+ ///
+ /// The item model to add.
public async Task Add(ItemModel model)
{
// Get the item
@@ -26,17 +36,32 @@ public class InventoryDataService : IInventoryDataService
await _http.PostAsJsonAsync("https://localhost:7234/api/Crafting/", item);
}
+ ///
+ /// Retrieves the number of items in the inventory.
+ ///
+ /// The number of items in the inventory.
public async Task Count()
{
return await _http.GetFromJsonAsync("https://localhost:7234/api/Crafting/count");
}
+ ///
+ /// Retrieves a list of items in the inventory.
+ ///
+ /// The current page number.
+ /// The number of items per page.
+ /// A list of items in the inventory.
public async Task> List(int currentPage, int pageSize)
{
_logger.LogInformation($".......List fetching........ <{currentPage}>;<{pageSize}>");
return await _http.GetFromJsonAsync>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
}
+ ///
+ /// Retrieves an item in the inventory by its ID.
+ ///
+ /// The ID of the item to retrieve.
+ /// The item with the specified ID.
public async Task- GetById(int id)
{
_logger.LogInformation($"Element with id....... <{id}>");
@@ -44,6 +69,11 @@ public class InventoryDataService : IInventoryDataService
return await _http.GetFromJsonAsync
- ($"https://localhost:7234/api/Crafting/{id}");
}
+ ///
+ /// Updates an item in the inventory.
+ ///
+ /// The ID of the item to update.
+ /// The updated item model.
public async Task Update(int id, ItemModel model)
{
// Get the item
@@ -53,6 +83,10 @@ public class InventoryDataService : IInventoryDataService
await _http.PutAsJsonAsync($"https://localhost:7234/api/Crafting/{id}", item);
}
+ ///
+ /// Deletes an item from the inventory.
+ ///
+ /// The ID of the item to delete.
public async Task Delete(int id)
{
_logger.LogInformation($"Deleting Element with id....... <{id}>");
@@ -60,6 +94,10 @@ public class InventoryDataService : IInventoryDataService
await _http.DeleteAsync($"https://localhost:7234/api/Crafting/{id}");
}
+ ///
+ ///
+
+
public async Task
> GetRecipes()
{
return await _http.GetFromJsonAsync>("https://localhost:7234/api/Crafting/recipe");