Esempio n. 1
0
        public static VotingAggregate CreateFrom(VotingSnapshot votingSnapshot)
        {
            var votingAggregate = new VotingAggregate();

            votingAggregate._winner     = votingSnapshot.Winner;
            votingAggregate._votingPair = VotingPair.CreateFrom(votingSnapshot.Topics);
            return(votingAggregate);
        }
Esempio n. 2
0
        private async Task <VotingAggregate> GetVotingAggregate(object @event)
        {
            var votingId = ((IVotingEvent)@event).VotingId;

            if (!_readModels.TryGetValue(votingId, out VotingSnapshot current))
            {
                return(await _repository.GetById <VotingAggregate>(votingId));
            }

            var aggregate = VotingAggregate.CreateFrom(current);

            aggregate.Apply((dynamic)@event);
            return(aggregate);
        }