Esempio n. 1
0
        public void AddPicture(Uri pictureUri, PictureSize size)
        {
            Apply(new Events.PictureAddedToAClassifiedAd
            {
                PictureId      = new Guid(),
                ClassifiedAdId = Id,
                Url            = pictureUri.ToString(),
                Height         = size.Height,
                Width          = size.Width,
                Order          = NewPictureOrder()
            });

            int NewPictureOrder() => Pictures.Any() ? Pictures.Max(x => x.Order) + 1 : 0;
        }
Esempio n. 2
0
        protected override void When(object @event)
        {
            switch (@event)
            {
            case Events.PictureAddedToClassifiedAd e:
                ParentId = new ClassifiedAdId(e.ClassifiedAdId);
                Id       = new PictureId(e.PictureId);
                Location = new Uri(e.Url);
                Size     = new PictureSize {
                    Height = e.Height, Width = e.Width
                };
                Order = e.Order;
                break;

            case Events.ClassifiedAdPictureResized e:
                Size = new PictureSize {
                    Height = e.Height, Width = e.Width
                };
                break;
            }
        }
Esempio n. 3
0
 public void Resize(PictureSize newSize) => Apply(new Events.ClassifiedAdPictureResized
 {
     PictureId = Id.Value,
     Width     = newSize.Width,
     Height    = newSize.Height
 });