コード例 #1
0
        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;
        }
コード例 #2
0
        public CatalogueDTO GetRandomCatalogue()
        {
            CatalogueDTO catalogueDto = new CatalogueDTO();

            CatalogueDAO dao = new CatalogueDAO();
            catalogueDto = dao.GetRandomCatalogue();

            //Random không dùng thông tin chi tiết nên không cần phải load
            //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;
        }
コード例 #3
0
        public int DeleteCatalogue(CatalogueDTO catalogue, SqlTransaction trans)
        {
            CatalogueDAO dao = new CatalogueDAO();
            CopyBUS copyBus = new CopyBUS();
            bool isInScopeCreated = false;

            int rs = 1;

            if (trans == null)
            {
                isInScopeCreated = true;
                trans = ConnectionManager.Con.BeginTransaction("CAT_DEL_TRANSACT");
            }

            List<CopyDTO> list = copyBus.GetCopyByISBN(catalogue.ISBN);
            foreach (CopyDTO copyDTO in list)
            {
                rs = rs & copyBus.DeleteCopy(copyDTO, trans);
                if (rs == 0)
                    break;
            }

            if (rs == 0)
            {
                if (isInScopeCreated)
                    trans.Rollback();
            }
            else
            {
                rs = rs & dao.DeleteCatalogue(catalogue, trans);

                if (isInScopeCreated)
                    if (rs == 0)
                        trans.Rollback();
                    else
                        trans.Commit();
            }

            return rs;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
 public int CountCatelogueByCategoryId(string categoryId)
 {
     CatalogueDAO dao = new CatalogueDAO();
     return dao.CountCatelogueByCategoryId(categoryId);
 }