Beispiel #1
0
 public void ChangeAuthor(AuthorFullName author, AuthorId authorId)
 {
     if (this.AuthorName == author)
     {
         throw new InvalidOperationException("Author name was already changed");
     }
     AddEvent(new BookAuthorNameChanged(Id.Value, this.Title.Value, authorId.Value, AuthorId.Value));
     this.AuthorId   = authorId;
     this.AuthorName = author;
 }
Beispiel #2
0
        public void UpdateAuthorFullName(AuthorFullName newAuthorFullName)
        {
            var oldAuthorName = authorFullName;

            if (authorFullName != newAuthorFullName)
            {
                authorFullName = newAuthorFullName;
                AddEvent(new AuthorUpdated(oldAuthorName, newAuthorFullName, (AuthorId)Id));
            }
        }
Beispiel #3
0
 private Book(BookId id, string title, string description, AuthorId authorId, AuthorFullName authorName)
 {
     Id          = id;
     Title       = new BookTitle(title);
     Description = description;
     AuthorId    = authorId;
     AuthorName  = authorName;
     State       = BookState.InDatabase;
     Amount      = new BookAmount(0);
 }
Beispiel #4
0
 private Author(AuthorId id, AuthorFullName authorFullName)
 {
     Id                  = id;
     this.Books          = new List <AuthorBookRecord>();
     this.authorFullName = authorFullName;
 }
Beispiel #5
0
        public static Author Create(AuthorFullName authorFullName)
        {
            var author = new Author(TypedId.GetNewId <AuthorId>(), authorFullName);

            return(author);
        }
Beispiel #6
0
        public static Book Create(string title, string description, AuthorId authorId, AuthorFullName authorName)
        {
            var book = new Book(
                TypedId.GetNewId <BookId>(), title, description, authorId, authorName);

            book.AddEvent(new BookCreated((BookId)book.Id, title, description, authorId));
            return(book);
        }
Beispiel #7
0
 public AuthorUpdated(AuthorFullName oldName, AuthorFullName newName, AuthorId authorId)
 {
     this.oldName  = oldName;
     this.newName  = newName;
     this.AuthorId = authorId;
 }