master
Darius BERTRAND 3 years ago
commit 73833f166e

@ -43,29 +43,29 @@ namespace Minecraft.Crafting.Api.Controllers
[Route("{id}")]
public Task Delete(int id)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
var data = JsonSerializer.Deserialize<List<Musique>>(System.IO.File.ReadAllText("Data/musique.json"), _jsonSerializerOptions);
var item = data?.FirstOrDefault(w => w.Id == id);
var item = data?.FirstOrDefault(w => w.id == id);
if (item == null)
{
throw new Exception($"Unable to found the item with ID: {id}");
}
data.Remove(item);
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
System.IO.File.WriteAllText("Data/musique.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}
[HttpGet]
[Route("{id}")]
public Task<Item> GetById(int id)
public Task<Musique> GetById(int id)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
var data = JsonSerializer.Deserialize<List<Musique>>(System.IO.File.ReadAllText("Data/musique.json"), _jsonSerializerOptions);
var item = data?.FirstOrDefault(w => w.Id == id);
var item = data?.FirstOrDefault(w => w.id == id);
if (item == null)
{
@ -148,37 +148,39 @@ namespace Minecraft.Crafting.Api.Controllers
[HttpGet]
[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());
}
[HttpPut]
[Route("{id}")]
public Task Update(int id, Item item)
public Task Update(int id, Musique musique)
{
var data = JsonSerializer.Deserialize<List<Item>>(System.IO.File.ReadAllText("Data/items.json"), _jsonSerializerOptions);
var data = JsonSerializer.Deserialize<List<Musique>>(System.IO.File.ReadAllText("Data/musique.json"), _jsonSerializerOptions);
var itemOriginal = data?.FirstOrDefault(w => w.Id == id);
var itemOriginal = data?.FirstOrDefault(w => w.id == id);
if (itemOriginal == null)
{
throw new Exception($"Unable to found the item with ID: {id}");
}
itemOriginal.Id = item.Id;
itemOriginal.Name = item.Name;
itemOriginal.CreatedDate = item.CreatedDate;
itemOriginal.DisplayName = item.DisplayName;
itemOriginal.EnchantCategories = item.EnchantCategories;
itemOriginal.MaxDurability = item.MaxDurability;
itemOriginal.RepairWith = item.RepairWith;
itemOriginal.StackSize = item.StackSize;
itemOriginal.UpdatedDate = item.UpdatedDate;
itemOriginal.id = musique.id;
itemOriginal.titre = musique.titre;
itemOriginal.auteur = musique.auteur;
itemOriginal.duree = musique.duree;
itemOriginal.genre = musique.genre;
itemOriginal.image = musique.image;
itemOriginal.date = musique.date;
System.IO.File.WriteAllText("Data/items.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
System.IO.File.WriteAllText("Data/musique.json", JsonSerializer.Serialize(data, _jsonSerializerOptions));
return Task.CompletedTask;
}

@ -0,0 +1,353 @@
[
{
"id": 1,
"titre": "Norali",
"auteur": "breakable",
"duree": 277,
"genre": "birch_planks",
"image": "Senmei",
"date": "1963-07-08T00:00:00"
},
{
"id": 2,
"titre": "Oulu",
"auteur": "digger",
"duree": 55,
"genre": "oak_planks",
"image": "Orbaxter",
"date": "2008-07-07T00:00:00"
},
{
"id": 3,
"titre": "Brainquil",
"auteur": "vanishable",
"duree": 634,
"genre": "jungle_planks",
"image": "Comvey",
"date": "2009-07-19T00:00:00"
},
{
"id": 4,
"titre": "Scenty",
"auteur": "armor_chest",
"duree": 2123,
"genre": "warped_planks",
"image": "Qimonk",
"date": "1965-09-07T00:00:00"
},
{
"id": 5,
"titre": "Wazzu",
"auteur": "armor",
"duree": 1653,
"genre": "acacia_planks",
"image": "UklGRjYHAABXRUJQVlA4ICoHAABwNwCdASoEARgBPjE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h6DPtcUgdcFvZCExUzspaDhVGD3pU/Lvl0bSzuaNRGrQy1BP8YLk3fUoLyCREh5BVhLm\u002Bz9vCLFGhIqYCyKDmn/mAeIbvfiebp83YSrqubtsESyhnYEdM\u002BOeKMo2EJcWyimVCu5Wz1sxwJ1Wue3wAHxO07rNLX0WtIbhfH/1CjJHQCIdhTtTJqk7p/zs1Zm\u002Bh0/whZ//u320SCHelgPN1OEKmZWk/qki1ZiR4\u002B8O3QKbfNyRKxmNW5UaTx5G9UW1ih6kcMYH6Zy4DukhYiRvUFbM84DjE\u002BWPmXx2Pj\u002Bor2jFE1M8o7uU\u002BcGrcaRQ069wr4WEiNssne/AhjtGnzRFAGl/dshGtxCj/sk0X50ZnPTwTd9igYdz04tpjUbgAAA",
"date": "1989-01-11T00:00:00"
},
{
"id": 6,
"titre": "Biolive",
"auteur": "armor_chest",
"duree": 2325,
"genre": "warped_planks",
"image": "Exoplode",
"date": "1964-04-10T00:00:00"
},
{
"id": 7,
"titre": "Quarx",
"auteur": "armor_chest",
"duree": 1984,
"genre": "birch_planks",
"image": "Venoflex",
"date": "1971-06-12T00:00:00"
},
{
"id": 8,
"titre": "Terrago",
"auteur": "vanishable",
"duree": 104,
"genre": "jungle_planks",
"image": "Vicon",
"date": "2015-05-23T00:00:00"
},
{
"id": 9,
"titre": "Isonus",
"auteur": "digger",
"duree": 1390,
"genre": "warped_planks",
"image": "Marqet",
"date": "2010-05-21T00:00:00"
},
{
"id": 10,
"titre": "Mobildata",
"auteur": "vanishable",
"duree": 242,
"genre": "oak_planks",
"image": "Xeronk",
"date": "1950-08-23T00:00:00"
},
{
"id": 11,
"titre": "Anocha",
"auteur": "breakable",
"duree": 1601,
"genre": "warped_planks",
"image": "Magnemo",
"date": "2020-11-19T00:00:00"
},
{
"id": 12,
"titre": "Songlines",
"auteur": "digger",
"duree": 3443,
"genre": "warped_planks",
"image": "Artiq",
"date": "2003-09-03T00:00:00"
},
{
"id": 13,
"titre": "Tellifly",
"auteur": "armor_head",
"duree": 2904,
"genre": "dark_oak_planks",
"image": "Geekko",
"date": "1965-10-25T00:00:00"
},
{
"id": 14,
"titre": "Skyplex",
"auteur": "digger",
"duree": 502,
"genre": "oak_planks",
"image": "Waab",
"date": "1971-08-26T00:00:00"
},
{
"id": 15,
"titre": "Sybixtex",
"auteur": "armor_head",
"duree": 2695,
"genre": "birch_planks",
"image": "Orbean",
"date": "2000-06-22T00:00:00"
},
{
"id": 16,
"titre": "Recritube",
"auteur": "vanishable",
"duree": 1013,
"genre": "oak_planks",
"image": "Xth",
"date": "1963-12-15T00:00:00"
},
{
"id": 17,
"titre": "Gluid",
"auteur": "armor_chest",
"duree": 1886,
"genre": "birch_planks",
"image": "Springbee",
"date": "1952-09-27T00:00:00"
},
{
"id": 18,
"titre": "Entogrok",
"auteur": "armor_chest",
"duree": 3047,
"genre": "spruce_planks",
"image": "Brainclip",
"date": "1990-02-03T00:00:00"
},
{
"id": 19,
"titre": "Turnabout",
"auteur": "armor_chest",
"duree": 1957,
"genre": "birch_planks",
"image": "Singavera",
"date": "2005-03-19T00:00:00"
},
{
"id": 20,
"titre": "Zolarex",
"auteur": "weapon",
"duree": 287,
"genre": "warped_planks",
"image": "Biohab",
"date": "1977-03-11T00:00:00"
},
{
"id": 21,
"titre": "Skybold",
"auteur": "digger",
"duree": 2819,
"genre": "warped_planks",
"image": "Momentia",
"date": "2003-02-22T00:00:00"
},
{
"id": 22,
"titre": "Extrawear",
"auteur": "breakable",
"duree": 114,
"genre": "spruce_planks",
"image": "Elemantra",
"date": "1999-02-26T00:00:00"
},
{
"id": 23,
"titre": "Lunchpad",
"auteur": "breakable",
"duree": 1322,
"genre": "spruce_planks",
"image": "Quordate",
"date": "1956-07-19T00:00:00"
},
{
"id": 24,
"titre": "Overplex",
"auteur": "weapon",
"duree": 3341,
"genre": "warped_planks",
"image": "Volax",
"date": "1994-11-28T00:00:00"
},
{
"id": 25,
"titre": "Geostele",
"auteur": "weapon",
"duree": 2761,
"genre": "acacia_planks",
"image": "Surelogic",
"date": "1981-07-20T00:00:00"
},
{
"id": 26,
"titre": "Buzzness",
"auteur": "digger",
"duree": 1522,
"genre": "spruce_planks",
"image": "Autograte",
"date": "1998-01-29T00:00:00"
},
{
"id": 27,
"titre": "Micronaut",
"auteur": "armor",
"duree": 1585,
"genre": "birch_planks",
"image": "Papricut",
"date": "2002-12-04T00:00:00"
},
{
"id": 28,
"titre": "Frosnex",
"auteur": "armor",
"duree": 241,
"genre": "oak_planks",
"image": "Freakin",
"date": "1957-01-09T00:00:00"
},
{
"id": 29,
"titre": "Cedward",
"auteur": "armor",
"duree": 225,
"genre": "acacia_planks",
"image": "Isopop",
"date": "1959-07-06T00:00:00"
},
{
"id": 30,
"titre": "Qualitern",
"auteur": "breakable",
"duree": 629,
"genre": "birch_planks",
"image": "Xoggle",
"date": "1965-04-15T00:00:00"
},
{
"id": 31,
"titre": "Equitox",
"auteur": "weapon",
"duree": 689,
"genre": "birch_planks",
"image": "Peticular",
"date": "1996-11-16T00:00:00"
},
{
"id": 32,
"titre": "Stockpost",
"auteur": "armor_chest",
"duree": 2062,
"genre": "crimson_planks",
"image": "Colaire",
"date": "1979-04-30T00:00:00"
},
{
"id": 33,
"titre": "Comtrek",
"auteur": "vanishable",
"duree": 2447,
"genre": "crimson_planks",
"image": "Reversus",
"date": "2018-09-20T00:00:00"
},
{
"id": 34,
"titre": "Darwinium",
"auteur": "armor",
"duree": 1580,
"genre": "jungle_planks",
"image": "Callflex",
"date": "2021-04-27T00:00:00"
},
{
"id": 35,
"titre": "Sportan",
"auteur": "armor",
"duree": 3491,
"genre": "crimson_planks",
"image": "Poochies",
"date": "1987-11-24T00:00:00"
},
{
"id": 36,
"titre": "Rotodyne",
"auteur": "armor",
"duree": 3295,
"genre": "jungle_planks",
"image": "Xixan",
"date": "1989-12-24T00:00:00"
},
{
"id": 37,
"titre": "Tribalog",
"auteur": "vanishable",
"duree": 1531,
"genre": "warped_planks",
"image": "Hivedom",
"date": "1995-06-17T00:00:00"
},
{
"id": 38,
"titre": "Exozent",
"auteur": "armor_chest",
"duree": 7,
"genre": "crimson_planks",
"image": "Lingoage",
"date": "1972-06-30T00:00:00"
},
{
"id": 39,
"titre": "Asimiline",
"auteur": "armor_chest",
"duree": 2048,
"genre": "dark_oak_planks",
"image": "Pearlesex",
"date": "2006-11-22T00:00:00"
}
]

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

@ -0,0 +1,35 @@
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Factories
{
public static class MusiqueFactory
{
public static MusiqueModel ToModel(Musique musique, byte[] imageContent)
{
return new MusiqueModel
{
id = musique.id,
titre = musique.titre,
auteur = musique.auteur,
genre = musique.genre,
duree = musique.duree,
date = musique.date,
image = imageContent
};
}
public static Musique Create(MusiqueModel musique)
{
return new Musique
{
id = musique.id,
titre = musique.titre,
auteur = musique.auteur,
duree = musique.duree,
genre = musique.genre,
date = musique.date,
image = musique.DisplayName
};
}
}
}

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

@ -1,9 +1,37 @@
using System.ComponentModel.DataAnnotations;
namespace ProjetBlazor.Modeles
{
public class MusiqueModel
{
public int id { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Le titre affiché ne doit pas dépasser 100 caractères.")]
public string titre { get; set; }
[Required]
[StringLength(50, ErrorMessage = "L'auteur affiché ne doit pas dépasser 50 caractères.")]
public string auteur { get; set; }
[Required]
[Range(1,3600)]
public int duree { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Le genre affiché ne doit pas dépasser 100 caractères.")]
public string genre { get; set; }
[Required(ErrorMessage = "La date de la musique est obligatoire !!")]
public DateTime date { get; set; }
[Required(ErrorMessage = "L'image de la musique est obligatoire !")]
public byte[] image { get; set; }
[Required]
[StringLength(50, ErrorMessage = "Le nom de la photo affiché ne doit pas dépasser 50 caractères.")]
public string DisplayName { get; set; }
}
}

@ -0,0 +1,58 @@
@page "/edit/{Id:int}"
<h3>Modification</h3>
<EditForm Model=@musiqueModele OnValidSubmit="@HandleValidSubmit">
<DataAnnotationsValidator />
<ValidationSummary />
<p>
<label for="titre">
Display Titre:
<InputText id="titre" @bind-Value="musiqueModele.titre" />
</label>
</p>
<p>
<label for="auteur">
Display Auteur:
<InputText id="auteur" @bind-Value="musiqueModele.auteur" />
</label>
</p>
<p>
<label for="duree">
Display Durée:
<InputNumber id="duree" @bind-Value="musiqueModele.duree" />
</label>
</p>
<p>
<label for="genre">
Display Genre:
<InputText id="genre" @bind-Value="musiqueModele.genre" />
</label>
</p>
<p>
<label for="image">
Display Image:
<InputFile id="image" OnChange="@LoadImage" accept=".png" />
</label>
</p>
<label for="display-name">
Display Name Image :
<InputText id="display-name" @bind-Value="musiqueModele.DisplayName" />
</label>
<p>
<label for="date">
Display Date:
<InputDate id="date" @bind-Value="musiqueModele.date" />
</label>
</p>
<button type="submit">Submit</button>
</EditForm>

@ -0,0 +1,126 @@
using Microsoft.AspNetCore.Components;
using ProjetBlazor.Services;
using ProjetBlazor.Modeles;
using Microsoft.AspNetCore.Components.Forms;
using ProjetBlazor.Factories;
namespace ProjetBlazor.Pages
{
public partial class Edit
{
[Parameter]
public int Id { get; set; }
private MusiqueModel musiqueModele = new MusiqueModel();
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
[Inject]
public IDataService DataService { get; set; }
/*
[Inject]
public NavigationManager NavigationManager { get; set; }
*/
/*
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
*/
/*
protected override async Task OnInitializedAsync()
{
var item = await DataService.GetById(Id);
var fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/default.png");
if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{itemModel.Name}.png"))
{
fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/{item.Name}.png");
}
// Set the model with the item
itemModel = ItemFactory.ToModel(item, fileContent);
}
private async void HandleValidSubmit()
{
await DataService.Update(Id, itemModel);
NavigationManager.NavigateTo("list");
}
private void OnEnchantCategoriesChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!itemModel.EnchantCategories.Contains(item))
{
itemModel.EnchantCategories.Add(item);
}
return;
}
if (itemModel.EnchantCategories.Contains(item))
{
itemModel.EnchantCategories.Remove(item);
}
}
private void OnRepairWithChange(string item, object checkedValue)
{
if ((bool)checkedValue)
{
if (!itemModel.RepairWith.Contains(item))
{
itemModel.RepairWith.Add(item);
}
return;
}
if (itemModel.RepairWith.Contains(item))
{
itemModel.RepairWith.Remove(item);
}
}
*/
private async void HandleValidSubmit()
{
await DataService.Update(Id,musiqueModele);
NavigationManager.NavigateTo("");
}
private async Task LoadImage(InputFileChangeEventArgs e)
{
// Set the content of the image to the model
using (var memoryStream = new MemoryStream())
{
await e.File.OpenReadStream().CopyToAsync(memoryStream);
musiqueModele.image = memoryStream.ToArray();
}
}
protected override async Task OnInitializedAsync()
{
var item = await DataService.GetById(Id);
var fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/default.png");
if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{musiqueModele.titre}.png"))
{
fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/{item.titre}.png");
}
// Set the model with the item
musiqueModele = MusiqueFactory.ToModel(item, fileContent);
}
}
}

@ -3,17 +3,27 @@ using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
<<<<<<< HEAD
=======
using ProjetBlazor.Services;
>>>>>>> 3440c9059da8cb9c6643c5187eb805ec45f4ec18
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
<<<<<<< HEAD
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
.AddFontAwesomeIcons();
=======
builder.Services.AddScoped<IDataService, DataApiService>();
builder.Services.AddHttpClient();
>>>>>>> 3440c9059da8cb9c6643c5187eb805ec45f4ec18
var app = builder.Build();

@ -7,9 +7,13 @@
</PropertyGroup>
<ItemGroup>
<<<<<<< HEAD
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.4.1" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.4.1" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.4.1" />
=======
<Folder Include="wwwroot\images\" />
>>>>>>> 3440c9059da8cb9c6643c5187eb805ec45f4ec18
</ItemGroup>
</Project>

@ -1,4 +1,5 @@
using ProjetBlazor.Modeles;
using ProjetBlazor.Factories;
using ProjetBlazor.Modeles;
namespace ProjetBlazor.Services
{
@ -11,18 +12,36 @@ namespace ProjetBlazor.Services
_http = http;
}
public async Task AddInPlaylist(Musique musique)
public async Task Add(MusiqueModel musique)
{
// Get the item
//var item = ItemFactory.Create(model);
var item = MusiqueFactory.Create(musique);
// 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 Delete(int id)
{
return await _http.GetFromJsonAsync<List<Musique>>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
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);
}
}
}

@ -4,8 +4,14 @@ namespace ProjetBlazor.Services
{
public interface IDataService
{
Task AddInPlaylist(Musique musique);
Task Add(MusiqueModel musique);
Task<List<Musique>> List(int currentPage, int pageSize);
Task Delete(int id);
Task Update(int id, MusiqueModel musique);
Task<Musique> GetById(int id);
}
}

@ -14,9 +14,15 @@
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</div>
<<<<<<< HEAD
<div class="nav-item px-3">
<NavLink class="nav-link" href="MusiquesListe">
<span class="oi oi-plus" aria-hidden="true"></span> MusiquesListe
=======
<div class="nav-item px-3">
<NavLink class="nav-link" href="edit/5/">
<span class="oi oi-plus" aria-hidden="true"></span> Edit
>>>>>>> 3440c9059da8cb9c6643c5187eb805ec45f4ec18
</NavLink>
</div>
</nav>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Loading…
Cancel
Save