diff --git a/Blazor/Blazor/Services/DataApiService.cs b/Blazor/Blazor/Services/DataApiService.cs index efea8e4..ca08edb 100644 --- a/Blazor/Blazor/Services/DataApiService.cs +++ b/Blazor/Blazor/Services/DataApiService.cs @@ -3,16 +3,27 @@ using Blazor.Factories; using Blazor.Models; namespace Blazor.Services -{ +{ + /// + /// Service for interacting with a data API. + /// public class DataApiService : IDataService { private readonly HttpClient _http; + /// + /// Constructor for DataApiService. + /// + /// HttpClient for making API requests. public DataApiService(HttpClient http) { _http = http; } + /// + /// Add a new item to the API. + /// + /// Model containing data for the new item. public async Task Add(ItemModel model) { // Get the item @@ -22,26 +33,50 @@ namespace Blazor.Services await _http.PostAsJsonAsync("https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/", item); } + /// + /// Get the number of items in the API. + /// + /// Task representing the asynchronous operation, returning the number of items. public async Task Count() { return await _http.GetFromJsonAsync("https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/count"); } + /// + /// Get a list of items from the API, paginated. + /// + /// The current page number. + /// The number of items per page. + /// Task representing the asynchronous operation, returning a list of items. public async Task> List(int currentPage, int pageSize) { return await _http.GetFromJsonAsync>($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}"); } + /// + /// Get a list of all items from the API. + /// + /// Task representing the asynchronous operation, returning a list of items. public async Task> getAll() { return await _http.GetFromJsonAsync>($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/all"); } + /// + /// Get a single item from the API by its ID. + /// + /// The ID of the item to retrieve. + /// Task representing the asynchronous operation, returning the item with the specified ID. public async Task GetById(int id) { return await _http.GetFromJsonAsync($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/{id}"); } + /// + /// Update an existing item in the API. + /// + /// The ID of the item to update. + /// Model containing the updated data for the item. public async Task Update(int id, ItemModel model) { // Get the item @@ -50,11 +85,19 @@ namespace Blazor.Services await _http.PutAsJsonAsync($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/{id}", item); } + /// + /// Delete an existing item from the API. + /// + /// The ID of the item to delete. public async Task Delete(int id) { await _http.DeleteAsync($"https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/{id}"); } + /// + /// Get a list of crafting recipes from the API. + /// + /// Task representing the asynchronous operation, returning a list of crafting recipes. public async Task> GetRecipes() { return await _http.GetFromJsonAsync>("https://codefirst.iut.uca.fr/containers/container-blazor-web-api-marcchevaldonne/api/Crafting/recipe");