Beispiel #1
0
        protected override void When(object e)
        {
            switch (e)
            {
            case Events.V1.ClassifiedAdRegistered x:
                Id    = new ClassifiedAdId(x.ClassifiedAdId);
                Owner = new OwnerId(x.Owner);
                break;

            case Events.V1.ClassifiedAdTitleChanged x:
                Title = new Title(x.Title);
                break;

            case Events.V1.ClassifiedAdTextChanged x:
                Text = new AdText(x.Text);
                break;

            case Events.V1.ClassifiedAdPriceChanged x:
                Price = new Price(x.Price);
                break;

            case Events.V1.ClassifiedAdPublished _:
                IsPublished = true;
                break;

            case Events.V1.ClassifiedAdSold _:
                WasSold = true;
                break;

            case Events.V1.ClassifiedAdRemoved _:
                WasRemoved = true;
                break;
            }
        }
Beispiel #2
0
        public void Register(ClassifiedAdId id, OwnerId owner, Func <DateTimeOffset> getUtcNow)
        {
            if (Version >= 0)
            {
                throw new ClassifiedAdAlreadyRegistered();
            }

            Apply(new Events.V1.ClassifiedAdRegistered
            {
                ClassifiedAdId = id,
                Owner          = owner,
                RegisteredAt   = getUtcNow()
            });
        }