Example #1
0
        private static void AssertBookCover(Book book, BookCover cover, IDbConnection conn)
        {
            var data = conn.QueryFirstOrDefault("select * from BookCover where RootId=@RootId and id=@id", new { RootId = book.Id, Id = cover.Id });

            if (cover.IsEmpty())
            {
                Assert.IsNull(data);
                return;
            }
            Assert.AreEqual(data.Number, cover.Number);
            Assert.AreEqual(data.Title, cover.Title);

            //验证cover 的  Author属性的信息
            var author = cover.Author;

            AssertAuthor(book, author, conn);

            //查询中间表
            var authorsData = conn.Query("select * from BookCover_Authors where RootId=@RootId and MasterId=@MasterId", new { RootId = book.Id, MasterId = cover.Id });

            Assert.AreEqual(authorsData.Count(), cover.Authors.Count());
            foreach (dynamic temp in authorsData)
            {
                var authorId = temp.SlaveId;
                var item     = cover.Authors.FirstOrDefault((t) =>
                {
                    return(t.Id == authorId);
                });
                AssertAuthor(book, item, conn);
            }
        }
Example #2
0
 public PhysicalBook(Guid id,
                     Bookmark mainBookmark,
                     BookCover cover,
                     DomainCollection <int> errorPageIndexs)
     : base(id, mainBookmark, cover, errorPageIndexs)
 {
     this.OnConstructed();
 }
Example #3
0
 public Book(Guid id,
             Bookmark mainBookmark,
             BookCover cover,
             DomainCollection <int> errorPageIndexs)
     : base(id)
 {
     this.MainBookmark = mainBookmark;
     this.Cover        = cover;
     _ErrorPageIndexs  = errorPageIndexs;
     this.OnConstructed();
 }
Example #4
0
        public static void FillBook(Book book)
        {
            var categoryMain = new BookCategory(15)
            {
                Name = "主要分类"
            };

            var category1 = new BookCategory(1)
            {
                Name = "分类1"
            };

            var category2 = new BookCategory(2)
            {
                Name = "分类2"
            };

            Author author1 = new Author("作者1", Sex.Female, Person.Empty);
            Author author2 = new Author("作者2", Sex.Male, Person.Empty);
            Author author3 = new Author("作者3", Sex.Male, Person.Empty);
            Author author4 = new Author("作者4", Sex.Female, Person.Empty);

            var autohrs = new Author[] { author1, author2, author3, author4 };


            var photo1        = new BookCover("照片1", "p1", new Author("照片1的作者", Sex.Male, Person.Empty), autohrs);
            var photo2        = new BookCover("照片2", "p2", new Author("照片2的作者", Sex.Female, Person.Empty), autohrs);
            var photo3        = new BookCover("照片3", "p3", new Author("照片3的作者", Sex.Female, Person.Empty), autohrs);
            var photo4        = new BookCover("照片4", "p4", new Author("照片4的作者", Sex.Male, Person.Empty), autohrs);
            var wuhanPhoto    = new BookCover("武汉的照片", "1", new Author("小王", Sex.Male, Person.Empty), autohrs);
            var beijingPhoto  = new BookCover("北京的照片", "2", new Author("老王", Sex.Male, Person.Empty), autohrs);
            var shangHaiPhoto = new BookCover("上海的照片", "3", new Author("小赵", Sex.Female, Person.Empty), autohrs);

            var wuhan = new BookAddress("武汉", BookCategory.Empty, new BookCover[] {
                wuhanPhoto, photo1, photo2
            });

            var beiJing = new BookAddress("北京", BookCategory.Empty, new BookCover[] {
                beijingPhoto, photo2, photo3
            });

            var shangHai = new BookAddress("上海", BookCategory.Empty, new BookCover[] {
                shangHaiPhoto, photo1, photo3
            });

            var bookMark1 = new Bookmark(1)
            {
                PageIndex = 1,
                Cover     = new BookCover("书签1的封面", "1", new Author("书签1的封面的作者", Sex.Female, Person.Empty), Array.Empty <Author>())
            };

            bookMark1.AddCover(photo1);
            bookMark1.AddCover(photo2);

            var bookMark18 = new Bookmark(2)
            {
                PageIndex = 18,
            };

            bookMark18.AddCover(photo1);
            bookMark18.AddCover(photo3);

            var bookMark20 = new Bookmark(3)
            {
                PageIndex = 20
            };

            bookMark20.AddCover(photo4);

            book.Name            = "第一本书";
            book.Category        = categoryMain;
            book.ErrorPageIndexs = new int[] { 1, 2, 3, 4, 5, 6 };
            book.SaleTime        = DateTime.Now;

            book.SetSignature("第一本书的个性签名");
            book.SetCreator(new Author("第一本书的作者", Sex.Female, Person.Empty));

            book.SetSignature2("第二个个性签名");

            book.Cover = new BookCover("主要的封面", "1", new Author("作者", Sex.Female, Person.Empty), autohrs);

            //添加相关分类
            book.AddRelatedCategory(category1);
            book.AddRelatedCategory(category2);

            book.SourceAddress = wuhan;
            book.AddSaleAddress(beiJing);
            book.AddSaleAddress(shangHai);

            book.MainBookmark  = bookMark1;
            book.FirstBookmark = bookMark1;
            book.LastBookmark  = bookMark18;

            book.AddBookmark(bookMark1);
            book.AddBookmark(bookMark18);
            book.AddBookmark(bookMark20);

            book.AddPoster(new BookPoster("第1个海报", "第1个提供商"));
            book.AddPoster(new BookPoster("第2个海报", "第2个提供商"));
            book.AddPoster(new BookPoster("第3个海报", "第3个提供商"));

            var reader1 = new BookReader(1)
            {
                Name = "张三丰",
                Sex  = Sex.Female
            };

            var reader2 = new BookReader(2)
            {
                Name = "周芷诺",
                Sex  = Sex.Male
            };

            bookMark1.AddReader(reader1);
            bookMark1.AddReader(reader2);

            {
                var repository = Repository.Create <IBookCategoryRepository>();
                repository.Add(categoryMain);
                repository.Add(category1);
                repository.Add(category2);
            }

            {
                var repository = Repository.Create <IBookRepository>();
                repository.Add(book);
            }
        }
Example #5
0
 public void AddCover(BookCover cover)
 {
     _Covers.Add(cover);
 }
Example #6
0
 public void AddPhoto(BookCover photo)
 {
     _Photos.Add(photo);
 }