It it now possible to create/edit item contents
This commit is contained in:
@@ -2,32 +2,33 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> decoratorItem,
|
||||
IDecoratorService<ItemConfiguration> decoratorItemConfiguration,
|
||||
public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> itemDecorator,
|
||||
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
|
||||
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)
|
||||
if (itemDecorator?.Service is Item<(Guid, string)> item &&
|
||||
itemConfigurationDecorator.Service is ItemConfiguration configuration)
|
||||
{
|
||||
var dd = decoratorItemConfiguration;
|
||||
publisher.Publish(Notify.As(new ItemHeader<string>(name)));
|
||||
if (decoratorItem?.Value is Item<(Guid, string)> item)
|
||||
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>,
|
||||
string>(Confirm.As<ItemHeader>());
|
||||
|
||||
if (name is not null)
|
||||
{
|
||||
publisher.Publish(Notify.As(new ItemHeader<string>(name)));
|
||||
|
||||
(Guid id, string _) = item.Value;
|
||||
|
||||
Item<(Guid, string)> newItem = new((id, name));
|
||||
publisher.Publish(Modified.As(item, newItem));
|
||||
|
||||
decoratorItem.Set(newItem);
|
||||
itemDecorator.Set(newItem);
|
||||
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, string, ItemConfiguration)>, bool>(new UpdateEventArgs<(Guid, string,
|
||||
ItemConfiguration)>((id, name, new ItemConfiguration())));
|
||||
await mediator.Handle<UpdateEventArgs<Item<(Guid, string, ItemConfiguration)>>, bool>(new UpdateEventArgs<Item<(Guid, string,
|
||||
ItemConfiguration)>>(new Item<(Guid, string, ItemConfiguration)>((id, name, configuration))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user