|
|
|
@ -14,18 +14,18 @@ namespace WF_WebAdmin.Pages
|
|
|
|
|
public ILogger<Edit>? Logger { get; set; }
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
private IQuoteService quoteService { get; set; }
|
|
|
|
|
private IQuoteService? quoteService { get; set; }
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
public NavigationManager? NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
private Quote q{ get; set; }
|
|
|
|
|
private Quote? Q { get; set; }
|
|
|
|
|
|
|
|
|
|
private QuoteModel quoteModel = new();
|
|
|
|
|
private QuoteModel _quoteModel = new();
|
|
|
|
|
|
|
|
|
|
private List<Character> charac = new List<Character>();
|
|
|
|
|
private List<Character> _charac = new List<Character>();
|
|
|
|
|
|
|
|
|
|
private List<Source> src = new List<Source>();
|
|
|
|
|
private List<Source> _src = new List<Source>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -37,23 +37,23 @@ namespace WF_WebAdmin.Pages
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
// Fetch the quote data based on the provided ID.
|
|
|
|
|
q = await quoteService.getOnequote(Id);
|
|
|
|
|
Q = await quoteService.getOnequote(Id);
|
|
|
|
|
|
|
|
|
|
// Populate the quoteModel with the data from the retrieved quote.
|
|
|
|
|
quoteModel.Content = q.Content;
|
|
|
|
|
quoteModel.Langue = q.Langue;
|
|
|
|
|
quoteModel.Charac = q.Charac;
|
|
|
|
|
quoteModel.TitleSrc = q.TitleSrc;
|
|
|
|
|
quoteModel.Id = q.Id;
|
|
|
|
|
quoteModel.Like = q.Like;
|
|
|
|
|
quoteModel.ImgPath = q.ImgPath;
|
|
|
|
|
quoteModel.DateSrc = q.DateSrc;
|
|
|
|
|
quoteModel.UserProposition = q.UserProposition;
|
|
|
|
|
quoteModel.IsValid = q.IsValid;
|
|
|
|
|
_quoteModel.Content = Q.Content;
|
|
|
|
|
_quoteModel.Langue = Q.Langue;
|
|
|
|
|
_quoteModel.Charac = Q.Charac;
|
|
|
|
|
_quoteModel.TitleSrc = Q.TitleSrc;
|
|
|
|
|
_quoteModel.Id = Q.Id;
|
|
|
|
|
_quoteModel.Like = Q.Like;
|
|
|
|
|
_quoteModel.ImgPath = Q.ImgPath;
|
|
|
|
|
_quoteModel.DateSrc = Q.DateSrc;
|
|
|
|
|
_quoteModel.UserProposition = Q.UserProposition;
|
|
|
|
|
_quoteModel.IsValid = Q.IsValid;
|
|
|
|
|
|
|
|
|
|
// Fetch additional data related to the quote, such as character and source.
|
|
|
|
|
charac = await quoteService.getChar();
|
|
|
|
|
src = await quoteService.getSrc();
|
|
|
|
|
_charac = await quoteService.getChar();
|
|
|
|
|
_src = await quoteService.getSrc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -64,15 +64,22 @@ namespace WF_WebAdmin.Pages
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected async Task HandleValidSubmit()
|
|
|
|
|
{
|
|
|
|
|
if (Q == null)
|
|
|
|
|
{
|
|
|
|
|
LoggerSaveStub.Log(Logger, LogLevel.Error, "Quote is null.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the properties of the selected quote (`q`) with the data from `quoteModel`.
|
|
|
|
|
LoggerSaveStub.Log(Logger, LogLevel.Information, $"Editing the quote {q.Content}");
|
|
|
|
|
q.Content = quoteModel.Content;
|
|
|
|
|
q.Langue = quoteModel.Langue;
|
|
|
|
|
q.TitleSrc = quoteModel.TitleSrc;
|
|
|
|
|
q.Charac = quoteModel.Charac;
|
|
|
|
|
LoggerSaveStub.Log(Logger, LogLevel.Information, $"Editing the quote {Q.Content}");
|
|
|
|
|
|
|
|
|
|
Q.Content = _quoteModel.Content ?? "Content";
|
|
|
|
|
Q.Langue = _quoteModel.Langue ?? "EN";
|
|
|
|
|
Q.TitleSrc = _quoteModel.TitleSrc ?? "Something";
|
|
|
|
|
Q.Charac = _quoteModel.Charac ?? "Someone";
|
|
|
|
|
|
|
|
|
|
// Call the quote service to update the quote in the data source.
|
|
|
|
|
await quoteService.updateQuote(q);
|
|
|
|
|
await quoteService.updateQuote(Q);
|
|
|
|
|
|
|
|
|
|
// Navigate to the "modifquote" page after updating the quote.
|
|
|
|
|
NavigationManager.NavigateTo("modifquote");
|
|
|
|
@ -87,13 +94,13 @@ namespace WF_WebAdmin.Pages
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The selected language ("fr" or "en") passed to the method.</param>
|
|
|
|
|
/// <param name="checkedValue">The checked value (unused in this method but may be used for other purposes).</param>
|
|
|
|
|
private void OnlangChange(string item, object checkedValue)
|
|
|
|
|
private void OnlangChange(string item)
|
|
|
|
|
{
|
|
|
|
|
// Check if the selected language is either "fr" or "en"
|
|
|
|
|
if (item == "fr" || item == "en")
|
|
|
|
|
{
|
|
|
|
|
// Update the Langue property of the quoteModel with the selected language
|
|
|
|
|
quoteModel.Langue = item;
|
|
|
|
|
_quoteModel.Langue = item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|