public CatalogueDTO GetCatalogueById(String isbn) { CatalogueDTO catalogueDto = new CatalogueDTO(); CatalogueDAO dao = new CatalogueDAO(); catalogueDto = dao.GetCatalogueById(isbn); if (catalogueDto != null) { PublisherBUS publisherBus = new PublisherBUS(); CategoryBUS categoryBus = new CategoryBUS(); AuthorOfBookBUS authorOfBookBus = new AuthorOfBookBUS(); catalogueDto.Publisher = publisherBus.GetPublisherById(catalogueDto.Publisher.PublisherId); catalogueDto.Category = categoryBus.GetCategoryById(catalogueDto.Category.CategoryId); catalogueDto.AuthorList = authorOfBookBus.GetAuthorListByIsbn(catalogueDto.ISBN); } return catalogueDto; }
public int UpdateCatalogue(CatalogueDTO catalogue, SqlTransaction trans) { AuthorOfBookBUS authorOfBookBus = new AuthorOfBookBUS(); bool isInScopeCreated = false; int rs = 1; if (trans == null) { isInScopeCreated = true; trans = ConnectionManager.Con.BeginTransaction("CAT_UPD_TRANSACT"); } rs = rs & authorOfBookBus.DeleteAuthorOfBook(catalogue.ISBN, trans); if (rs == 0) { if (isInScopeCreated) trans.Rollback(); } else { for (int i = 0; i < catalogue.AuthorList.Count; i++) { rs = rs & authorOfBookBus.InsertAuthorOfBook(catalogue.AuthorList.ElementAt(i), trans); if (rs == 0) break; } if (rs == 0) { if (isInScopeCreated) trans.Rollback(); } else { CatalogueDAO dao = new CatalogueDAO(); rs = rs & dao.UpdateCatalogue(catalogue, trans); if (isInScopeCreated) { if (rs == 0) trans.Rollback(); else trans.Commit(); } } } return rs; }