Пример #1
0
 public void SetTitle(ClassifiedAdTitle title) =>
 Apply(
     new Events.ClassifiedAdTitleChanged
 {
     Id    = Id,
     Title = title
 }
     );
Пример #2
0
        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;

            case Events.ClassifiedAdPublished e:
                ApprovedBy = new UserId(e.ApprovedBy);
                State      = ClassifiedAdState.Active;
                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;
            }
        }
        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;
                Pictures = new List <Picture>();
                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, e.InUse, e.DecimalPlaces);
                break;

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

            case Events.ClassifiedAdPublished e:
                ApprovedBy = new UserId(e.ApprovedBy);
                State      = ClassifiedAdState.Active;
                break;

            case Events.PictureAddedToClassifiedAd e:
                var 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;
            }
        }