From 9f1af3ca86e2a40e2bff3bef74a1023a4154f686 Mon Sep 17 00:00:00 2001 From: NICK BRAIN Date: Sat, 7 Dec 2024 19:27:58 +0200 Subject: [PATCH] + RedoSample uses validation --- My1kWordsEe/Components/Pages/WordPage.razor | 6 +++++- My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs | 6 +++--- My1kWordsEe/ee1k.json | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/My1kWordsEe/Components/Pages/WordPage.razor b/My1kWordsEe/Components/Pages/WordPage.razor index a27e5b1..af10a4b 100644 --- a/My1kWordsEe/Components/Pages/WordPage.razor +++ b/My1kWordsEe/Components/Pages/WordPage.razor @@ -23,6 +23,7 @@ @inject RemoveFromFavoritesCommand RemoveFromFavoritesCommand @inject DeleteSampleSentenceCommand DeleteSampleSentenceCommand @inject RedoSampleWordCommand RedoSampleWordCommand +@inject ValidateSampleWordCommand ValidateSampleWordCommand @code { @@ -145,7 +146,10 @@ if (confirmation) { PreloadService.Show(SpinnerColor.Light, "Saving data..."); - var redoResult = await this.RedoSampleWordCommand.Invoke(Value.EeWord); + + var redoResult = await this.ValidateSampleWordCommand.Invoke(Value).Bind(r => + this.RedoSampleWordCommand.Invoke(Value.EeWord, r.EeExplanationMessage)); + if (redoResult.IsSuccess) { WordMetadata = redoResult; diff --git a/My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs b/My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs index 2f3fca2..daa5954 100644 --- a/My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs +++ b/My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs @@ -31,7 +31,7 @@ public async Task> Invoke(string eeWord, string? comment = nu (await azureBlobService.GetWordData(eeWord)).Deconstruct( out bool _, out bool isBlobAccessFailure, - out Maybe savedWord, + out Maybe existingWordData, out string blobAccessError); if (isBlobAccessFailure) @@ -41,9 +41,9 @@ public async Task> Invoke(string eeWord, string? comment = nu var redoTask = this.addSampleWordCommand.Invoke(eeWord, comment); - if (savedWord.HasValue) + if (existingWordData.HasValue) { - await Parallel.ForEachAsync(savedWord.Value.Samples, async (sample, ct) => + await Parallel.ForEachAsync(existingWordData.Value.Samples, async (sample, ct) => { if (ct.IsCancellationRequested) { return; } await deleteSampleSentenceCommand.Invoke(sample); diff --git a/My1kWordsEe/ee1k.json b/My1kWordsEe/ee1k.json index 4d5935c..4dbb1b6 100644 --- a/My1kWordsEe/ee1k.json +++ b/My1kWordsEe/ee1k.json @@ -2227,9 +2227,9 @@ }, { "EeWord": "eks", - "EnWord": "ex", - "EnWords": [ "formerly", "was", "in the past" ], - "EnExplanation": "A word used to indicate something that was or someone who was in a previous state or role, often referring to a former partner or spouse." + "EnWord": "isn't it", + "EnWords": [ "right", "isn't that so", "indeed" ], + "EnExplanation": "The word 'eks' is often used in Estonian as a tag question, similar to 'isn't it?' or 'right?', or as an interjection meaning 'indeed' or 'really'." }, { "EeWord": "ringi",