public Task SaveAsync <T>(T aggregate) where T : Aggregate
        {
            var task = aggregateStore.Save(aggregate);

            #region Snapshot check & save it!

            Console.WriteLine("snapshot check");
            if (aggregate is ISnapshottable <T> snapshottable)
            {
                Console.WriteLine("snapshot check:true");

                if (snapshottable.SnapshotFrequency().Invoke())
                {
                    Console.WriteLine("taking snapshot...");
                    snapshotStore.SaveSnapshotAsync(snapshottable.TakeSnapshot());
                }
            }
            #endregion

            return(task);
        }
Beispiel #2
0
 public Task Handle(Contracts.Reviews.V1.ReviewCreate command) =>
 aggrigateStore.Save(Domain.Review.Create(command.Id, command.Owner, command.Caption, command.Content));