예제 #1
0
        public IBookCore Seed()
        {
            var container = Database.CleanDatabase();
            var core      = container.Resolve <IBookCore>();

            _book = new Book {
                Title = "This is a test book"
            };
            _author = new Author {
                FirstName = "Tom", LastName = "Clancy"
            };
            _publisher = new Publisher {
                Name = "Wiley Publishing"
            };
            _book.AddAuthor(_author);
            _book.AddPublisher(_publisher);
            _bookFile = new BookFile {
                FullPathAndFileName = @"C:\test.pdf"
            };
            _book.AddBookFile(_bookFile);
            core.Persist(_book);

            _book2 = new Book {
                Title = "This is another test book"
            };
            _author2 = new Author {
                FirstName = "David", LastName = "Jones"
            };
            _publisher2 = new Publisher {
                Name = "Microsoft Press"
            };
            _book2.AddAuthor(_author2);
            _book2.AddPublisher(_publisher2);
            core.Persist(_book2);

            _book3 = new Book {
                Title = "This is another another test book"
            };
            _author3 = new Author {
                FirstName = "David", LastName = "Jones"
            };
            _publisher3 = new Publisher {
                Name = "Microsoft Press"
            };
            _book3.AddAuthor(_author3);
            _book3.AddPublisher(_publisher3);
            core.Persist(_book3);
            return(core);
        }