コード例 #1
0
    public async Task <ICommandResult> HandleAsync(ProjectUserDeleteCommand command, IAsyncCollector <ICommand> commandQueue, IDurableOrchestrationContext orchestrationContext, ILogger log)
    {
        if (command is null)
        {
            throw new ArgumentNullException(nameof(command));
        }

        if (commandQueue is null)
        {
            throw new ArgumentNullException(nameof(commandQueue));
        }

        var commandResult = command.CreateResult();

        try
        {
            commandResult.Result = await userRepository
                                   .RemoveAsync(command.Payload)
                                   .ConfigureAwait(false);

            commandResult.RuntimeStatus = CommandRuntimeStatus.Completed;
        }
        catch (Exception exc)
        {
            commandResult.Errors.Add(exc);
        }
        finally
        {
            await UpdateComponentsAsync(command.User, command.ProjectId, commandQueue)
            .ConfigureAwait(false);
        }

        return(commandResult);
    }