Пример #1
0
 static BookAddress()
 {
     NameProperty       = DomainProperty.Register <string, BookAddress>("Name");
     CategoryProperty   = DomainProperty.Register <BookCategory, BookAddress>("Category", (owner) => BookCategory.Empty);
     CategoriesProperty = DomainProperty.RegisterCollection <BookCategory, BookAddress>("Categories");
     PhotoProperty      = DomainProperty.Register <BookCover, BookAddress>("Photo", (owner) => BookCover.Empty);
     PhotosProperty     = DomainProperty.RegisterCollection <BookCover, BookAddress>("Photos");
     Empty = new BookAddressEmpty();
 }
Пример #2
0
        private static void AssertBookAddress(Book book, BookAddress obj, IDbConnection conn)
        {
            var data = conn.QueryFirstOrDefault("select * from BookAddress where  RootId=@RootId and id=@id", new { RootId = book.Id, Id = obj.Id });

            if (obj.IsEmpty())
            {
                Assert.IsNull(data);
                return;
            }
            Assert.AreEqual(data.Name, obj.Name);
            Assert.AreEqual(data.CategoryId, obj.Category.Id);
            AssertBookCategory(obj.Category, conn);

            var categoryDatas = conn.Query("select * from BookAddress_Categories where RootId=@RootId and MasterId=@MasterId", new { RootId = book.Id, MasterId = obj.Id });

            AssertBookCategories(categoryDatas, obj.Categories, conn);

            AssertBookCover(book, obj.Photo, conn);
            var photoDatas = conn.Query("select * from BookAddress_Photos where RootId=@RootId and MasterId=@MasterId", new { RootId = book.Id, MasterId = obj.Id });

            AssertBookCovers(book, photoDatas, obj.Photos, conn);
        }
Пример #3
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);
            }
        }
Пример #4
0
 public void AddSaleAddress(BookAddress address)
 {
     _SaleAddresses.Add(address);
 }