master
enjolys 3 years ago
parent 56c80d6b42
commit a50f28454a

@ -148,13 +148,16 @@ namespace Minecraft.Crafting.Api.Controllers
[HttpGet] [HttpGet]
[Route("")] [Route("")]
public Task<List<Item>> List(int currentPage, int pageSize) public Task<List<Musique>> List(int currentPage, int pageSize)
{ {
var data = JsonSerializer.Deserialize<List<Musique>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions); var data = JsonSerializer.Deserialize<List<Musique>>(System.IO.File.ReadAllText("Data/musique.json"), _jsonSerializerOptions);
return Task.FromResult(data.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList()); return Task.FromResult(data.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList());
} }
[HttpPut] [HttpPut]
[Route("{id}")] [Route("{id}")]
public Task Update(int id, Item item) public Task Update(int id, Item item)

@ -2,6 +2,7 @@
{ {
public class Musique public class Musique
{ {
public int id { get; set; }
public string titre { get; set; } public string titre { get; set; }
public string auteur { get; set; } public string auteur { get; set; }
public int duree { get; set; } public int duree { get; set; }

@ -2,7 +2,7 @@
{ {
public class Musique public class Musique
{ {
public int id { get; set; } public int id { get; set; }
public string titre { get; set; } public string titre { get; set; }
public string auteur { get; set; } public string auteur { get; set; }
public int duree { get; set; } public int duree { get; set; }

@ -11,18 +11,18 @@ namespace ProjetBlazor.Services
_http = http; _http = http;
} }
public async Task AddInPlaylist(Musique musique) public async Task Add(Musique musique)
{ {
// Get the item // Get the item
//var item = ItemFactory.Create(model); //var item = ItemFactory.Create(model);
// Save the data // Save the data
await _http.PostAsJsonAsync("https://localhost:7234/api/", musique); await _http.PostAsJsonAsync("https://localhost:7234/api/controleur/", musique);
} }
public Task<List<Musique>> List(int currentPage, int pageSize) public async Task<List<Musique>> List(int currentPage, int pageSize)
{ {
return await _http.GetFromJsonAsync<List<Musique>>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}"); return await _http.GetFromJsonAsync<List<Musique>>($"https://localhost:7234/api/controleur/?currentPage={currentPage}&pageSize={pageSize}");
} }
} }
} }

@ -4,7 +4,7 @@ namespace ProjetBlazor.Services
{ {
public interface IDataService public interface IDataService
{ {
Task AddInPlaylist(Musique musique); Task Add(Musique musique);
Task<List<Musique>> List(int currentPage, int pageSize); Task<List<Musique>> List(int currentPage, int pageSize);
} }

Loading…
Cancel
Save