You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

using ProjetBlazor.Factories;
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Services
{
public class DataApiService : IDataService
{
private readonly HttpClient _http;
public DataApiService(HttpClient http)
{
_http = http;
}
public async Task Add(MusiqueModel musique)
{
// Get the item
var item = MusiqueFactory.Create(musique);
// Save the data
await _http.PostAsJsonAsync("https://localhost:7234/api/controleur/", musique);
}
public async Task Delete(int id)
{
await _http.DeleteAsync($"https://localhost:7234/api/Crafting/{id}");
}
public async Task<Musique> GetById(int id)
{
return await _http.GetFromJsonAsync<Musique>($"https://localhost:7234/api/Crafting/{id}");
}
public async Task<List<Musique>> List(int currentPage, int pageSize)
{
return await _http.GetFromJsonAsync<List<Musique>>($"https://localhost:7234/api/controleur/?currentPage={currentPage}&pageSize={pageSize}");
}
public async Task Update(int id, MusiqueModel musique)
{
// Get the item
var item = MusiqueFactory.Create(musique);
await _http.PutAsJsonAsync($"https://localhost:7234/api/Crafting/{id}", musique);
}
}
}