Beispiel #1
0
        protected override void When(object @event)
        {
            switch (@event)
            {
            case Events.ClassifiedAdCreated e:
                Id      = new ClassifiedAdId(e.Id);
                OwnerId = new UserId(e.OwnerId);
                State   = ClassifiedAdState.Inactive;
                break;

            case Events.ClassifiedAdTitleChanged e:
                Title = new ClassifiedAdTitle(e.Title);
                break;

            case Events.ClassifiedAdTextUpdated e:
                Text = new ClassifiedAdText(e.AdText);
                break;

            case Events.ClassifiedAdPriceUpdated e:
                Price = new Price(e.Price, e.CurrencyCode);
                break;

            case Events.ClassifiedAdSentForReview e:
                State = ClassifiedAdState.PendingReview;
                break;
            }
        }
Beispiel #2
0
 public void UpdateText(ClassifiedAdText text) =>
 Apply(
     new Events.ClassifiedAdTextUpdated
 {
     Id     = Id,
     AdText = text
 }
     );
Beispiel #3
0
        public void UpdateText(ClassifiedAdText text)
        {
            Text = text;
            EnsureValidState();

            Apply(new Events.ClassifiedAdTextUpdated
            {
                AdText = text,
                Id     = Id
            });
        }
        protected override void When(object @event)
        {
            Picture picture;

            switch (@event)
            {
            case Events.ClassifiedAdCreated e:
                Id      = new ClassifiedAdId(e.Id);
                OwnerId = new UserId(e.OwnerId);
                State   = ClassifiedAdState.Inactive;

                Title      = ClassifiedAdTitle.NoTitle;
                Text       = ClassifiedAdText.NoText;
                Price      = Price.NoPrice;
                ApprovedBy = UserId.NoUser;

                ClassifiedAdId = e.Id;
                break;

            case Events.ClassifiedAdTitleChanged e:
                Title = new ClassifiedAdTitle(e.Title);
                break;

            case Events.ClassifiedAdTextUpdated e:
                Text = new ClassifiedAdText(e.AdText);
                break;

            case Events.ClassifiedAdPriceUpdated e:
                Price = new Price(e.Price, e.CurrencyCode);
                break;

            case Events.ClassidiedAdSentForReview _:
                State = ClassifiedAdState.PendingReview;
                break;

            // picture
            case Events.PictureAddedToAClassifiedAd e:
                picture = new Picture(Apply);
                ApplyToEntity(picture, e);
                Pictures.Add(picture);
                break;

            case Events.ClassifiedAdPictureResized e:
                picture = FindPicture(new PictureId(e.PictureId));
                ApplyToEntity(picture, @event);
                break;
            }
        }