Exemple #1
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);
        }
Exemple #2
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;
 }
Exemple #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);
 }
Exemple #4
0
 private Author(AuthorId id, AuthorFullName authorFullName)
 {
     Id                  = id;
     this.Books          = new List <AuthorBookRecord>();
     this.authorFullName = authorFullName;
 }
Exemple #5
0
 public AuthorUpdated(AuthorFullName oldName, AuthorFullName newName, AuthorId authorId)
 {
     this.oldName  = oldName;
     this.newName  = newName;
     this.AuthorId = authorId;
 }