28 lines
985 B
C#
28 lines
985 B
C#
using Toolkit.Foundation;
|
|
|
|
namespace Bitvault;
|
|
|
|
public class ConfirmCreateItemHandler(IMediator mediator,
|
|
IPublisher publisher) :
|
|
INotificationHandler<ConfirmEventArgs<Item>>
|
|
{
|
|
public async Task Handle(ConfirmEventArgs<Item> args)
|
|
{
|
|
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>,
|
|
string>(Confirm.As<ItemHeader>());
|
|
|
|
if (name is not null)
|
|
{
|
|
IList<ItemEntryConfiguration?> entries = await mediator.HandleMany<ConfirmEventArgs<ItemContentEntry>,
|
|
ItemEntryConfiguration>(Confirm.As<ItemContentEntry>());
|
|
|
|
Guid id = Guid.NewGuid();
|
|
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
|
|
|
|
await mediator.Handle<CreateEventArgs<(Guid, string, string,
|
|
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, ItemConfiguration)>((id, name, "",
|
|
new ItemConfiguration())));
|
|
}
|
|
}
|
|
}
|