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; }
public void UpdateAuthorFullName(AuthorFullName newAuthorFullName) { var oldAuthorName = authorFullName; if (authorFullName != newAuthorFullName) { authorFullName = newAuthorFullName; AddEvent(new AuthorUpdated(oldAuthorName, newAuthorFullName, (AuthorId)Id)); } }
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); }
private Author(AuthorId id, AuthorFullName authorFullName) { Id = id; this.Books = new List <AuthorBookRecord>(); this.authorFullName = authorFullName; }
public static Author Create(AuthorFullName authorFullName) { var author = new Author(TypedId.GetNewId <AuthorId>(), authorFullName); return(author); }
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); }
public AuthorUpdated(AuthorFullName oldName, AuthorFullName newName, AuthorId authorId) { this.oldName = oldName; this.newName = newName; this.AuthorId = authorId; }