Example #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;
            }
        }
Example #2
0
 public void SetTitle(ClassifiedAdTitle title) =>
 Apply(
     new Events.ClassifiedAdTitleChanged
 {
     Id    = Id,
     Title = title
 }
     );
Example #3
0
        public void SetTitle(ClassifiedAdTitle title)
        {
            Title = title;
            EnsureValidState();

            Apply(new Events.ClassifiedAdTitleChanged
            {
                Id    = Id,
                Title = title
            });
        }
        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;
            }
        }