//[Obsolete] //public bool Export2(int bookID, string ftpPath) //{ // //kontrola vstupnich parametru // if (bookID == 0) // throw new ArgumentNullException("book"); // bool result = false; // BookRepository repository = new BookRepository(); // //kontrola existence publikace // Book book = repository.Select(bookID); // if (book == null) // throw new ArgumentNullException(String.Format("Záznam publikace (ID={0}) neexistuje.", bookID)); // if (book.FrontCover != null && book.FrontCover.Status == StatusCode.Exported) // { // ScanFileComponent.Instance.Export2(book.FrontCover.ScanFileID, ftpPath); // result = true; // } // if (book.TableOfContents != null && book.TableOfContents.Status == StatusCode.Exported) // { // ScanFileComponent.Instance.Export2(book.TableOfContents.ScanFileID, ftpPath); // result = true; // } // return result; //} public bool Delete(int bookID, string userName) { if (bookID == 0) throw new ArgumentNullException("bookID"); if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Neplatný parametr jméno uživatele."); BookRepository repository = new BookRepository(); Book book = repository.Select(bookID); //kontrola existence publikace if (book == null) throw new ApplicationException(String.Format("Publikace (ID={0}) neexistuje.", bookID)); if (book.IsExported()) throw new ApplicationException(String.Format("Publikace (ID={0}) byla již exportována do ALEPHu, nelze vymazat.", bookID)); //vymazani obalky if (book.HasPartOfBook(PartOfBook.FrontCover)) { ScanFileComponent.Instance.Delete(book.FrontCover.ScanFileID, userName); } //vymazani obsahu if (book.HasPartOfBook(PartOfBook.TableOfContents)) { ScanFileComponent.Instance.Delete(book.TableOfContents.ScanFileID, userName); } try { return repository.Delete(book); } catch (Exception ex) { throw new ApplicationException(String.Format("Nepodařilo se vymazat data publikace (ID={0}) z databáze.", bookID), ex); } }