コード例 #1
0
        public void Cancel()
        {
            if (Status == ESongStatus.Promoted || Status == ESongStatus.Released || Status == ESongStatus.Canceled)
            {
                StatusChangeException(ESongStatus.Canceled);
            }

            Status = ESongStatus.Canceled;

            AddDomainEvent(new SongCanceledDomainEvent(Id));
        }
コード例 #2
0
        public void Release()
        {
            if (Status != ESongStatus.Promoted)
            {
                StatusChangeException(ESongStatus.Released);
            }

            Status = ESongStatus.Released;

            AddDomainEvent(new SongReleasedDomainEvent(Id));
        }
コード例 #3
0
        private Song(string name, string description, double duration, string durationFormatted, List <string> tags, Author author)
        {
            Name              = name;
            Description       = description;
            Duration          = duration;
            DurationFormatted = durationFormatted;
            _tags             = tags;
            _files            = new List <File>();
            Audit             = Audit.Create(DateTimeOffset.Now, author.UserName);
            Status            = ESongStatus.Pending;

            AddSongCreatedDomainEvent(Id, name, durationFormatted, Draft, author.UserName);
        }
コード例 #4
0
        public void Promote()
        {
            if (Status != ESongStatus.Pending)
            {
                StatusChangeException(ESongStatus.Promoted);
            }
            if (Duration < 3)
            {
                throw new DomainException("A song cannot be promoted if the duration is less than 4 minutes");
            }

            Status = ESongStatus.Promoted;

            AddDomainEvent(new SongPromotedDomainEvent(Id));
        }
コード例 #5
0
 private void StatusChangeException(ESongStatus songStatusToChange)
 {
     throw new SongDomainException($"Is not possible to change the order status from {Status.Name} to {songStatusToChange.Name}.");
 }