public static async Task UpdateAsync <TEventSourcedAggregate, TId>(
            this IEventSourcedRepository <TEventSourcedAggregate, TId> repository,
            TId id,
            Action <TEventSourcedAggregate> action,
            CancellationToken token = default)
            where TEventSourcedAggregate : EventSourcedAggregate <TId>
            where TId : notnull
        {
            var aggregate = await repository.GetAsync(id, token) ??
                            throw new EntityNotFoundException(typeof(TEventSourcedAggregate).Name, id);

            action(aggregate);

            await repository.SaveAsync(aggregate, token);
        }
コード例 #2
0
 public Task <Account?> GetAsync(AccountId id, CancellationToken token = default)
 {
     return(_eventSourcedRepository.GetAsync(id, token));
 }