Exemplo n.º 1
0
 public static IAggregate <TBoundedContext> CreateInstance(
     IAnemicModel <TBoundedContext> anemicModel,
     IAggregate <TBoundedContext> currentAggregate,
     CommandToAggregate command)
 => new Aggregate <TBoundedContext>(
     anemicModel,
     currentAggregate);
Exemplo n.º 2
0
 internal AggregateResult(
     IAggregate <TBoundedContext> aggregate,
     CommandToAggregate command,
     IDictionary <string, IValueObject> changedValueObjects)
 {
     _aggregate   = aggregate;
     _domainEvent = new DomainEvent <TBoundedContext>(
         aggregate.Id, command, changedValueObjects);
 }
Exemplo n.º 3
0
 public IAggregate <TBoundedContext> NewAggregate(IAnemicModel <TBoundedContext> anemicModel, CommandToAggregate command)
 => Aggregate <TBoundedContext> .CreateInstance(anemicModel, _scope);
Exemplo n.º 4
0
        public IAggregate <TBoundedContext> GetAggregateByIdAndVersion(Guid id, int version, CommandToAggregate command)
        {
            var anemicModel = _unitOfWork.QueryRepository.GetQueryable()
                              .Single(f => f.Id == id && f.Version == version);
            var aggregate = Aggregate <TBoundedContext>
                            .CreateInstance(anemicModel, _scope);

            return(aggregate);
        }
Exemplo n.º 5
0
 public IAggregate <TBoundedContext> GetAggregateByIdAndVersion(Guid id, CommandToAggregate command)
 => _unitOfWork.QueryRepository.GetQueryable()
 .Where(f => f.Id == id)
 .Max(f => f.Version)
 .PipeTo(version => GetAggregateByIdAndVersion(id, command));
Exemplo n.º 6
0
 private CommandToAggregate NewCommand()
 => CommandToAggregate.Commit(Guid.NewGuid(), "Test", "Test");
Exemplo n.º 7
0
 public AggregateResult <TBoundedContext> Handle(
     IAnemicModel <TBoundedContext> input,
     CommandToAggregate command,
     IBoundedContextScope <TBoundedContext> scope)
 => input.Id
 .Either(c => c == default, s => command.CorrelationToken, n => n)
Exemplo n.º 8
0
 /// <summary>
 /// Создание экземпляра комплексного ключа полностью из данных о команде к агрегату,
 /// т.е. с использованием маркера корреляции.
 /// </summary>
 /// <param name="command"></param>
 /// <returns></returns>
 public static ComplexKey CreateWithUsingCorrelationToken(CommandToAggregate command)
 => new ComplexKey(command.CorrelationToken, command.Version, command.CorrelationToken);
Exemplo n.º 9
0
 /// <summary>
 /// Создание экземляра комплексного ключа.
 /// </summary>
 /// <param name="id">Идентификатор агрегата.</param>
 /// <param name="command">Комманда к агрегату.</param>
 /// <returns></returns>
 public static ComplexKey Create(Guid id, CommandToAggregate command)
 => new ComplexKey(id, command);
Exemplo n.º 10
0
 private ComplexKey(Guid id, CommandToAggregate command)
     : this(id, command.Version, command.CorrelationToken)
 {
 }