public Book GetBookById(object id) { Book book = null; using (var unity = new UnityOfWork()) { book = new BookBdRepository(unity).GetById(id); unity.Complete(); } return(book); }
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); }
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); }