public HandlingEvent(Book book, LibraryAccount account, Library library, HandlingType handlingType) : base(Guid.NewGuid()) { Assert.IsValid(book); Assert.IsValid(account); Assert.IsValid(library); OnEvent(new HandlingEventCreated(Id, book.Id, account.Id, library.Id, handlingType, DateTime.Now)); }
/// <summary> /// 图书馆接收归还的书 /// </summary> /// <param name="book"></param> /// <param name="account"></param> /// <param name="count"></param> public void ReceiveBook(Book book, LibraryAccount account, int count) { Assert.IsValid(book); Assert.Greater(count, 0); var bookStoreItem = _bookStoreItems.SingleOrDefault(x => x.BookId == book.Id); Assert.IsNotNull(bookStoreItem); OnEvent(new BookReceived(Id, book.Id, account.Id, count)); OnAggregateRootCreated(new HandlingEvent(book, account, this, HandlingType.Return)); }