示例#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;
            }
        }
        protected override void When(object e)
        {
            switch (e)
            {
            case Events.V1.ClassifiedAdCreated x:
                Id     = x.Id;
                _title = x.Title;
                break;

            case Events.V1.ClassifiedAdRenamed x:
                _title = x.Title;
                break;

            case Events.V1.ClassifiedAdTextUpdated x:
                _text = x.AdText;
                break;

            case Events.V1.ClassifiedAdPriceChanged x:
                _price = x.Price;
                break;

            case Events.V1.ClassifiedAdPublished x:
                _isPublished = true;
                break;

            case Events.V1.ClassifiedAdMarkedAsSold x:
                _sold = true;
                break;
            }
        }
示例#3
0
        public void ChangeText(AdText text, Func <DateTimeOffset> getUtcNow)
        {
            if (Version == -1)
            {
                throw new ClassifiedAdNotFound();
            }

            if (WasRemoved)
            {
                throw new ClassifiedAdRemoved();
            }

            if (Text != AdText.Default && Text == text)
            {
                return;
            }

            Apply(new Events.V1.ClassifiedAdTextChanged
            {
                ClassifiedAdId = Id,
                Owner          = Owner,
                Text           = text,
                ChangedAt      = getUtcNow()
            });
        }
 public void UpdateText(AdText text, UserId updatedBy) =>
 Apply(new Events.V1.ClassifiedAdTextUpdated
 {
     Id            = Id,
     AdText        = text,
     TextUpdatedBy = updatedBy
 });
 public void UpdateText(AdText text, DateTimeOffset updatedAt, UserId updatedBy) =>
 Apply(new Events.V1.ClassifiedAdTextUpdated
 {
     Id            = Id,
     Owner         = _owner,
     AdText        = text,
     TextUpdatedAt = updatedAt,
     TextUpdatedBy = updatedBy
 });
        public async Task UpdateText(AdText text, UserId updatedBy, Func <DateTimeOffset> getUtcNow, CheckTextForProfanity checkTextForProfanity)
        {
            if (Version == -1)
            {
                throw new Exceptions.ClassifiedAdNotFoundException();
            }

            var containsProfanity = await checkTextForProfanity(text);

            if (containsProfanity)
            {
                throw new Exceptions.ProfanityFound();
            }

            Apply(new Events.V1.ClassifiedAdTextUpdated
            {
                Id            = Id,
                Owner         = _owner,
                AdText        = text,
                TextUpdatedBy = updatedBy,
                TextUpdatedAt = getUtcNow()
            });
        }
 public void UpdateText(AdText text, DateTimeOffset updatedAt, UserId updatedBy)
 {
 }