Skip to content

Commit

Permalink
+ RedoSample uses validation
Browse files Browse the repository at this point in the history
  • Loading branch information
NicklausBrain committed Dec 7, 2024
1 parent 2db9159 commit 9f1af3c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion My1kWordsEe/Components/Pages/WordPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@inject RemoveFromFavoritesCommand RemoveFromFavoritesCommand
@inject DeleteSampleSentenceCommand DeleteSampleSentenceCommand
@inject RedoSampleWordCommand RedoSampleWordCommand
@inject ValidateSampleWordCommand ValidateSampleWordCommand


@code {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions My1kWordsEe/Services/Cqs/RedoSampleWordCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task<Result<SampleWord>> Invoke(string eeWord, string? comment = nu
(await azureBlobService.GetWordData(eeWord)).Deconstruct(
out bool _,
out bool isBlobAccessFailure,
out Maybe<SampleWord> savedWord,
out Maybe<SampleWord> existingWordData,
out string blobAccessError);

if (isBlobAccessFailure)
Expand All @@ -41,9 +41,9 @@ public async Task<Result<SampleWord>> 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);
Expand Down
6 changes: 3 additions & 3 deletions My1kWordsEe/ee1k.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9f1af3c

Please sign in to comment.