prevent dup wallets

This commit is contained in:
TheXamlGuy
2024-07-23 18:20:58 +01:00
parent 8e0f1e6715
commit f30ee9fe70
4 changed files with 49 additions and 28 deletions
+10 -3
View File
@@ -50,8 +50,15 @@ public partial class CreateWalletViewModel :
{
using (await new ActivityLock(this))
{
IsConfirmed = await Mediator.Handle<CreateEventArgs<Wallet<(string, string, IImageDescriptor?)>>,
bool>(Create.As(new Wallet<(string, string, IImageDescriptor?)>((Name, Password, ImageDescriptor))));
if (await Mediator.Handle<CreateEventArgs<Wallet<(string, string, IImageDescriptor?)>>,
Result>(Create.As(new Wallet<(string, string, IImageDescriptor?)>((Name, Password, ImageDescriptor)))) is Result result)
{
if (await Validation.Validate(() => Name, [new ValidationRule(() => result.Error != Error.Duplicated,
"This wallet name already exist.")]))
{
IsConfirmed = true;
}
}
return IsConfirmed;
}
@@ -68,7 +75,7 @@ public partial class CreateWalletViewModel :
{
if (args.PropertyName is string name)
{
_ = Validation.Validate(name);
Validation.Validate(name);
}
base.OnPropertyChanged(args);