@ -1,7 +1,9 @@
using Blazorise.DataGrid ;
using Blazorise.DataGrid ;
using Microsoft.AspNetCore.Components ;
using Microsoft.AspNetCore.Components ;
using Microsoft.Extensions.Localization ;
using Microsoft.Extensions.Localization ;
using System ;
using System.Security.Claims ;
using System.Security.Claims ;
using System.Text.Json ;
using WF_WebAdmin.Model ;
using WF_WebAdmin.Model ;
@ -32,9 +34,18 @@ namespace WF_WebAdmin.Pages
Dailyquote = await Http . GetFromJsonAsync < Quote [ ] > ( $"{NavigationManager.BaseUri}fake-dataDailyQuote.json" ) ;
Dailyquote = await Http . GetFromJsonAsync < Quote [ ] > ( $"{NavigationManager.BaseUri}fake-dataDailyQuote.json" ) ;
}
}
private void RandomDailyquote ( )
private async void RandomDailyquote ( )
{
{
//fonction a compléter
string _jsonFilePath = Path . Combine ( Environment . CurrentDirectory , "wwwroot" , "fake-dataDailyQuote.json" ) ;
Random random = new Random ( ) ;
Quote [ ] quotes = await Http . GetFromJsonAsync < Quote [ ] > ( $"{NavigationManager.BaseUri}fake-dataQuote.json" ) ;
Dailyquote = new Quote [ ] { quotes . OrderBy ( x = > random . Next ( ) ) . First ( ) } ;
var json = JsonSerializer . Serialize ( Dailyquote , new JsonSerializerOptions { WriteIndented = true } ) ;
await File . WriteAllTextAsync ( _jsonFilePath , json ) ;
LoggerSaveStub . Log ( Logger , LogLevel . Information , "Random change of quote of the day" ) ;
LoggerSaveStub . Log ( Logger , LogLevel . Information , "Random change of quote of the day" ) ;
}
}
}
}