From 278018f651d86fa76c6a1b9aa01932b5c488fb33 Mon Sep 17 00:00:00 2001 From: pasquizzat Date: Fri, 18 Nov 2022 11:59:24 +0100 Subject: [PATCH] ok ptit retour en arriere :rewind: on en est au coding live mais le truc pour crafter marche plus... --- .../CetteAppliVaMarcher.csproj | 1 + .../CetteAppliVaMarcher/Pages/Index.razor | 12 +++-- .../CetteAppliVaMarcher/Pages/Index.razor.cs | 13 +++-- .../CetteAppliVaMarcher/Program.cs | 3 ++ .../Services/DataLocalService.cs | 50 ------------------- .../wwwroot/appsettings.json | 9 ++++ 6 files changed, 28 insertions(+), 60 deletions(-) create mode 100644 CetteAppliVaMarcher/CetteAppliVaMarcher/wwwroot/appsettings.json diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/CetteAppliVaMarcher.csproj b/CetteAppliVaMarcher/CetteAppliVaMarcher/CetteAppliVaMarcher.csproj index f2eba01..0a8a8c3 100644 --- a/CetteAppliVaMarcher/CetteAppliVaMarcher/CetteAppliVaMarcher.csproj +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/CetteAppliVaMarcher.csproj @@ -12,6 +12,7 @@ + diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor b/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor index 0c75033..f962e81 100644 --- a/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor @@ -1,8 +1,14 @@ @using System.Globalization +@using CetteAppliVaMarcher.Components +@using CetteAppliVaMarcher.Models @page "/" Index +

+ CurrentCulture: @CultureInfo.CurrentCulture +

+

Hello, world!

Welcome to your new app. @@ -11,8 +17,4 @@ Welcome to your new app.
-
- -

- CurrentCulture: @CultureInfo.CurrentCulture -

\ No newline at end of file + \ No newline at end of file diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor.cs b/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor.cs index 4db766e..3443126 100644 --- a/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor.cs +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/Pages/Index.razor.cs @@ -3,12 +3,15 @@ using CetteAppliVaMarcher.Models; using CetteAppliVaMarcher.Services; using Microsoft.AspNetCore.Components; -public partial class Index +namespace CetteAppliVaMarcher.Pages { - [Inject] - public IDataService DataService { get; set; } + public partial class Index + { + [Inject] + public IDataService DataService { get; set; } - public List Items { get; set; } = new List(); + public List Items { get; set; } = new List(); - private List Recipes { get; set; } = new List(); + private List Recipes { get; set; } = new List(); + } } \ No newline at end of file diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/Program.cs b/CetteAppliVaMarcher/CetteAppliVaMarcher/Program.cs index c19b14c..b9b700d 100644 --- a/CetteAppliVaMarcher/CetteAppliVaMarcher/Program.cs +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/Program.cs @@ -10,6 +10,7 @@ using Blazored.Modal; using Microsoft.AspNetCore.Localization; using System.Globalization; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Logging; var builder = WebApplication.CreateBuilder(args); @@ -44,6 +45,8 @@ builder.Services.Configure(options => options.SupportedUICultures = new List { new CultureInfo("en-US"), new CultureInfo("fr-FR") }; }); +builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/Services/DataLocalService.cs b/CetteAppliVaMarcher/CetteAppliVaMarcher/Services/DataLocalService.cs index b306af8..76c7090 100644 --- a/CetteAppliVaMarcher/CetteAppliVaMarcher/Services/DataLocalService.cs +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/Services/DataLocalService.cs @@ -36,21 +36,6 @@ namespace CetteAppliVaMarcher.Services // Add the item to the current data 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 await _localStorage.SetItemAsync("data", currentData); } @@ -105,32 +90,6 @@ namespace CetteAppliVaMarcher.Services 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 ItemFactory.Update(item, model); @@ -148,15 +107,6 @@ namespace CetteAppliVaMarcher.Services // Delete item in 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 await _localStorage.SetItemAsync("data", currentData); } diff --git a/CetteAppliVaMarcher/CetteAppliVaMarcher/wwwroot/appsettings.json b/CetteAppliVaMarcher/CetteAppliVaMarcher/wwwroot/appsettings.json new file mode 100644 index 0000000..2a1e03d --- /dev/null +++ b/CetteAppliVaMarcher/CetteAppliVaMarcher/wwwroot/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Trace", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} \ No newline at end of file