Ejemplo n.º 1
0
        //InsertIntoDB(Ibook,IAuthor,ICSV)
        public void InsertIntoDB(List <AuthorBook> items, IBookDAL bookDAL, IAuthorDAL authorDAL)
        {
            var book   = new Book();
            var author = new Author();

            foreach (var item in items)
            {
                author.authorName = item.authorName;
                book.bookName     = item.bookName;
                if (authorDAL.SearchAuthorByName(author.authorName) == null)
                {
                    ;
                }
                {
                    authorDAL.InsertAuthor(author);
                }

                book.authorId = authorDAL.SearchAuthorByName(author.authorName).id;
                bookDAL.InsertBook(book);
            }
        }