Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
oskogstad committed Aug 14, 2024
1 parent b094df1 commit 50d8af5
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal sealed class CreateDialogCommandHandler : IRequestHandler<CreateDialogC
private readonly IUserResourceRegistry _userResourceRegistry;
private readonly IUserOrganizationRegistry _userOrganizationRegistry;
private readonly IPartyNameRegistry _partyNameRegistry;
private readonly IResourceRegistry _resourceRegistry;

internal static readonly ValidationFailure ProgressValidationFailure = new(nameof(CreateDialogCommand.Progress), "Progress cannot be set for correspondence dialogs.");

Expand All @@ -40,7 +41,8 @@ public CreateDialogCommandHandler(
IDomainContext domainContext,
IUserResourceRegistry userResourceRegistry,
IUserOrganizationRegistry userOrganizationRegistry,
IPartyNameRegistry partyNameRegistry)
IPartyNameRegistry partyNameRegistry,
IResourceRegistry resourceRegistry)
{
_db = db ?? throw new ArgumentNullException(nameof(db));
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
Expand All @@ -49,6 +51,7 @@ public CreateDialogCommandHandler(
_userResourceRegistry = userResourceRegistry ?? throw new ArgumentNullException(nameof(userResourceRegistry));
_userOrganizationRegistry = userOrganizationRegistry ?? throw new ArgumentNullException(nameof(userOrganizationRegistry));
_partyNameRegistry = partyNameRegistry ?? throw new ArgumentNullException(nameof(partyNameRegistry));
_resourceRegistry = resourceRegistry ?? throw new ArgumentNullException(nameof(resourceRegistry));
}

public async Task<CreateDialogResult> Handle(CreateDialogCommand request, CancellationToken cancellationToken)
Expand All @@ -63,6 +66,14 @@ public async Task<CreateDialogResult> Handle(CreateDialogCommand request, Cancel
}
}
}
else
{
if (!_resourceRegistry.ServiceResourceExists())
{
return new ValidationError(new ValidationFailure(nameof(CreateDialogCommand.ServiceResource),
$"Could not find service resource '{request.ServiceResource}' in resource registry"));
}
}

var serviceResourceType = await _userResourceRegistry.GetResourceType(request.ServiceResource, cancellationToken);

Expand Down

0 comments on commit 50d8af5

Please sign in to comment.