public void Update(ChapterDataBrief chapter) { if (chapter is Chapter db) { Debug.Assert(db.BookId == BookId); Debug.Assert(db.ChapterId == ChapterId); Debug.Assert(db.Book == Book || db.Book is null || Book is null); } Title = chapter.Title; VolumeTitle = chapter.VolumeTitle.CoalesceNullOrWhiteSpace(VolumeTitle); UpdateTime = chapter.UpdateTime ?? UpdateTime; if (chapter.WordCount >= 0) { WordCount = chapter.WordCount; } Key = chapter.Key; Preview = chapter.Preview.CoalesceNullOrWhiteSpace(Preview); if (chapter is ChapterDataDetailed detailed) { Content = detailed.Content.CoalesceNullOrWhiteSpace(Content); } }
public Chapter(int bookId, int chapterId, ChapterDataBrief item) { this.BookId = bookId; this.ChapterId = chapterId; Update(item); }
public Chapter(Book book, int chapterId, ChapterDataBrief item) : this(book.Id, chapterId, item) { this.Book = book; }