Add ability to fully delete items from the DB

This commit is contained in:
TheXamlGuy
2024-06-23 09:58:19 +01:00
parent 95de9d187f
commit db20ee15cc
18 changed files with 98 additions and 22 deletions
+30
View File
@@ -0,0 +1,30 @@
using Toolkit.Foundation;
namespace Wallet;
public class ConfirmDeleteItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorService,
ICache<Item<(Guid, string)>> cache,
IMediator mediator,
IPublisher publisher) :
INotificationHandler<DeleteEventArgs<Item>>
{
public async Task Handle(DeleteEventArgs<Item> args)
{
try
{
if (decoratorService.Service is Item<(Guid, string)> item)
{
(Guid id, string name) = item.Value;
await mediator.Handle<DeleteEventArgs<Item<Guid>>,
bool>(new DeleteEventArgs<Item<Guid>>(new Item<Guid>(id)));
cache.Add(item);
publisher.Publish(Changed.As<Item>());
}
}
catch
{
}
}
}