Ejemplo n.º 1
0
        public bool Handle(DomainEventHandlerData <UpgradeCastleEvent> @event)
        {
            var snap   = @event.Snapshot as GameAggregate;
            var castle = snap?.Castles.FirstOrDefault(e => e.Id == @event.EventObject.CastleId);

            if (castle == null)
            {
                return(false);
            }
            castle.Strength++;
            var coins = _domainService.GetCoinsToUpgradeCastle(castle.Strength);

            _domain.AddEvent(snap.Id, new DeficitCoinsEvent(coins, castle.Army, castle.OwnerUserId));
            return(true);
        }