예제 #1
0
        public Book GetBookById(object id)
        {
            Book book = null;

            using (var unity = new UnityOfWork())
            {
                book = new BookBdRepository(unity).GetById(id);

                unity.Complete();
            }

            return(book);
        }
예제 #2
0
        public Book GetBookById(object id)
        {
            Book book = null;

            using (var unity = new UnityOfWork())
            {
                book = new BookBdRepository(unity).GetById(id);
                book.AddSubjects(new SubjectBdRepository(unity).GetSubjectsOfABook(book));
                book.AddAuthors(new AuthorBdRepository(unity).GetAuthorsOfABook(book));

                unity.Complete();
            }

            return(book);
        }
예제 #3
0
        public IEnumerable <Book> GetAllBooks()
        {
            IEnumerable <Book> books;

            using (UnityOfWork unity = new UnityOfWork())
            {
                books = new BookBdRepository(unity).GetAll();
                var subjectRep = new SubjectBdRepository(unity);
                var authorRep  = new AuthorBdRepository(unity);
                foreach (var book in books)
                {
                    book.AddSubjects(subjectRep.GetSubjectsOfABook(book));
                    book.AddAuthors(authorRep.GetAuthorsOfABook(book));
                }

                unity.Complete();
            }

            return(books);
        }