Beispiel #1
0
 public FruitCreatedEvent(string id, decimal weight, FruitCondition condition, TypeOfFruit typeOfFruit)
 {
     Id          = id;
     Weight      = weight;
     Condition   = condition;
     TypeOfFruit = typeOfFruit;
 }
        private void Summon(string fruitId, decimal weight, FruitCondition condition, TypeOfFruit type)
        {
            var ev = new FruitCreatedEvent(fruitId, weight, condition, type);

            _events.Add(ev);

            Apply((dynamic)ev);
        }
        public static FruitAggregate CreateNew(string fruitId, decimal weight, FruitCondition condition, TypeOfFruit type)
        {
            var agg = new FruitAggregate();

            agg.Summon(fruitId, weight, condition, type);

            return(agg);
        }
Beispiel #4
0
        public async Task Handle(string basketId, string fruitId, decimal weight, FruitCondition condition)
        {
            var basket = await _basketProjection.Project(basketId);

            basket.AddFruit(new Pear(fruitId, weight, condition));

            await _store.Add("basket", basketId, basket.Events);
        }
        public async Task Handle(string fruitId, decimal weight, FruitCondition condition, Domains.Basket.Events.TypeOfFruit typeOfFruit)
        {
            var fruit = await new ProjectionFromFruit <FruitAggregate>(FruitAggregate.Replay).Project(fruitId);

            if (fruit != null)
            {
                throw new System.Exception("Can not summon a fruit that exists");
            }

            var agg = FruitAggregate.CreateNew(fruitId, weight, condition, typeOfFruit);

            await _store.Add("fruit", fruitId, agg.Events);
        }
 public Apple(string id, decimal weight, FruitCondition fruitCondition)
 {
     Id             = id;
     Weight         = weight;
     FruitCondition = fruitCondition;
 }
Beispiel #7
0
 public AppleAddedEvent(string id, decimal weight, FruitCondition fruitCondition) : base(id, TypeOfThing.Fruit, weight)
 {
     FruitCondition = fruitCondition;
 }