ok ptit retour en arriere on en est au coding live mais le truc pour crafter marche plus...

master
pasquizzat 2 years ago
parent 78796e1197
commit 278018f651

@ -12,6 +12,7 @@
<PackageReference Include="Blazorise.Bootstrap" Version="1.1.2" /> <PackageReference Include="Blazorise.Bootstrap" Version="1.1.2" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.2" /> <PackageReference Include="Blazorise.DataGrid" Version="1.1.2" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.2" /> <PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -1,8 +1,14 @@
@using System.Globalization @using System.Globalization
@using CetteAppliVaMarcher.Components
@using CetteAppliVaMarcher.Models
@page "/" @page "/"
<PageTitle>Index</PageTitle> <PageTitle>Index</PageTitle>
<p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p>
<h1>Hello, world!</h1> <h1>Hello, world!</h1>
Welcome to your new app. Welcome to your new app.
@ -12,7 +18,3 @@ Welcome to your new app.
<div> <div>
<Crafting Items="Items" Recipes="Recipes" /> <Crafting Items="Items" Recipes="Recipes" />
</div> </div>
<p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p>

@ -3,12 +3,15 @@ using CetteAppliVaMarcher.Models;
using CetteAppliVaMarcher.Services; using CetteAppliVaMarcher.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
public partial class Index namespace CetteAppliVaMarcher.Pages
{ {
[Inject] public partial class Index
public IDataService DataService { get; set; } {
[Inject]
public IDataService DataService { get; set; }
public List<Item> Items { get; set; } = new List<Item>(); public List<Item> Items { get; set; } = new List<Item>();
private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>(); private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>();
}
} }

@ -10,6 +10,7 @@ using Blazored.Modal;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using System.Globalization; using System.Globalization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -44,6 +45,8 @@ builder.Services.Configure<RequestLocalizationOptions>(options =>
options.SupportedUICultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; options.SupportedUICultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("fr-FR") };
}); });
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

@ -36,21 +36,6 @@ namespace CetteAppliVaMarcher.Services
// Add the item to the current data // Add the item to the current data
currentData.Add(ItemFactory.Create(model)); currentData.Add(ItemFactory.Create(model));
// Save the image
var imagePathInfo = new DirectoryInfo($"{_webHostEnvironment.WebRootPath}/images");
// Check if the folder "images" exist
if (!imagePathInfo.Exists)
{
imagePathInfo.Create();
}
// Determine the image name
var fileName = new FileInfo($"{imagePathInfo}/{model.Name}.png");
// Write the file content
await File.WriteAllBytesAsync(fileName.FullName, model.ImageContent);
// Save the data // Save the data
await _localStorage.SetItemAsync("data", currentData); await _localStorage.SetItemAsync("data", currentData);
} }
@ -105,32 +90,6 @@ namespace CetteAppliVaMarcher.Services
throw new Exception($"Unable to found the item with ID: {id}"); throw new Exception($"Unable to found the item with ID: {id}");
} }
// Save the image
var imagePathInfo = new DirectoryInfo($"{_webHostEnvironment.WebRootPath}/images");
// Check if the folder "images" exist
if (!imagePathInfo.Exists)
{
imagePathInfo.Create();
}
// Delete the previous image
if (item.Name != model.Name)
{
var oldFileName = new FileInfo($"{imagePathInfo}/{item.Name}.png");
if (oldFileName.Exists)
{
File.Delete(oldFileName.FullName);
}
}
// Determine the image name
var fileName = new FileInfo($"{imagePathInfo}/{model.Name}.png");
// Write the file content
await File.WriteAllBytesAsync(fileName.FullName, model.ImageContent);
// Modify the content of the item // Modify the content of the item
ItemFactory.Update(item, model); ItemFactory.Update(item, model);
@ -148,15 +107,6 @@ namespace CetteAppliVaMarcher.Services
// Delete item in // Delete item in
currentData.Remove(item); currentData.Remove(item);
// Delete the image
var imagePathInfo = new DirectoryInfo($"{_webHostEnvironment.WebRootPath}/images");
var fileName = new FileInfo($"{imagePathInfo}/{item.Name}.png");
if (fileName.Exists)
{
File.Delete(fileName.FullName);
}
// Save the data // Save the data
await _localStorage.SetItemAsync("data", currentData); await _localStorage.SetItemAsync("data", currentData);
} }

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Loading…
Cancel
Save