public static IAggregate <TBoundedContext> CreateInstance( IAnemicModel <TBoundedContext> anemicModel, IAggregate <TBoundedContext> currentAggregate, CommandToAggregate command) => new Aggregate <TBoundedContext>( anemicModel, currentAggregate);
internal AggregateResult( IAggregate <TBoundedContext> aggregate, CommandToAggregate command, IDictionary <string, IValueObject> changedValueObjects) { _aggregate = aggregate; _domainEvent = new DomainEvent <TBoundedContext>( aggregate.Id, command, changedValueObjects); }
public IAggregate <TBoundedContext> NewAggregate(IAnemicModel <TBoundedContext> anemicModel, CommandToAggregate command) => Aggregate <TBoundedContext> .CreateInstance(anemicModel, _scope);
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); }
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));
private CommandToAggregate NewCommand() => CommandToAggregate.Commit(Guid.NewGuid(), "Test", "Test");
public AggregateResult <TBoundedContext> Handle( IAnemicModel <TBoundedContext> input, CommandToAggregate command, IBoundedContextScope <TBoundedContext> scope) => input.Id .Either(c => c == default, s => command.CorrelationToken, n => n)
/// <summary> /// Создание экземпляра комплексного ключа полностью из данных о команде к агрегату, /// т.е. с использованием маркера корреляции. /// </summary> /// <param name="command"></param> /// <returns></returns> public static ComplexKey CreateWithUsingCorrelationToken(CommandToAggregate command) => new ComplexKey(command.CorrelationToken, command.Version, command.CorrelationToken);
/// <summary> /// Создание экземляра комплексного ключа. /// </summary> /// <param name="id">Идентификатор агрегата.</param> /// <param name="command">Комманда к агрегату.</param> /// <returns></returns> public static ComplexKey Create(Guid id, CommandToAggregate command) => new ComplexKey(id, command);
private ComplexKey(Guid id, CommandToAggregate command) : this(id, command.Version, command.CorrelationToken) { }