Exemplo n.º 1
0
        async Task IdempotentlyCreateAgg(string id, Action <PersonAggregate> usingThisMethod)
        {
            var agg = await AggRepository.GetAsync <PersonAggregate>(id).ConfigureAwait(false);

            if (agg == null)
            {
                agg = new PersonAggregate(new PersonAggregateState());
            }
            var ov = agg.Version;

            usingThisMethod(agg);
            PublishedEvents = agg.PublishedEvents;
            if (ov != agg.Version)
            {
                await AggRepository.StoreAsync(agg).ConfigureAwait(false);
            }
        }
Exemplo n.º 2
0
 public static void Rename(PersonAggregate agg, string newName)
 {
     agg.Rename(new RenamePerson {
         Id = agg.Id, Name = newName
     });
 }