Exemple #1
0
        public BookErrorCodes AddNewBook(string title, string author, double cost, long ISBN, int shelfID)
        {
            var existingShelf = shelfManager.GetShelf(shelfID);

            if (existingShelf == null)
            {
                return(BookErrorCodes.NoSuchShelf);
            }
            if (ValidateISBN(ISBN) == false)
            {
                return(BookErrorCodes.IncorrectISBN);
            }
            var sameBooks = bookManager.GetListOfBooksByTitle(title);

            if (sameBooks.Count > 0)
            {
                bookManager.AddBook(title, author, cost, ISBN, sameBooks.First().ShelfID);
                return(BookErrorCodes.OkButBookIsPutInAnotherShelfWithExistingBooks);
            }
            else
            {
                bookManager.AddBook(title, author, cost, ISBN, shelfID);
            }
            return(BookErrorCodes.ok);
        }
Exemple #2
0
        public ShelfErrorCodes RemoveShelf(int shelfID)
        {
            var shelf = shelfManager.GetShelf(shelfID);

            if (shelf == null)
            {
                return(ShelfErrorCodes.NoSuchShelf);
            }
            else
            {
                if (shelf.Books != null)
                {
                    return(ShelfErrorCodes.TheShelfContainsBooks);
                }
                else
                {
                    shelfManager.RemoveShelf(shelf);
                }
                return(ShelfErrorCodes.ok);
            }
        }