public async Task <Unit> Handle(CreateContract command, CancellationToken cancellationToken)
        {
            var contract = new Contract(command.ClientId);
            await _repository.SaveAsync(contract, cancellationToken);

            return(Unit.Value);
        }
        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);
        }
Beispiel #3
0
 public Task SaveAsync(Account aggregate, CancellationToken token = default)
 {
     return(_eventSourcedRepository.SaveAsync(aggregate, token));
 }