Example #1
0
        public void AddBook(Book book)
        {
            //TODO: validate if the user is admin

            // add new title if the title doesnt already exist
            if (!bookDao.CheckIfBookTitleExists(book.Title))
            {
                //set default genre to General and default to 100
                if (book.Genre.Count == 0)
                {
                    AddTitle(book.Title, book.Author, book.Rating, book.Price == null ? 100 : book.Price, "General");
                }
                else
                {
                    AddTitle(book.Title, book.Author, book.Rating, book.Price == null ? 100 : book.Price, book.Genre[0]);

                    //for multiple genres
                    for (int i = 1; i < book.Genre.Count; i++)
                    {
                        bookDao.AddNewGenreToTitle(book.Title, book.Author, book.Genre[i]);
                    }
                }
            }
            else
            {
                bookDao.AddBook(book.Title);
            }
        }
 public void AddRental(string titleName, string userName, int?noOfDaysToIssueFor)
 {
     if (bookDao.CheckIfBookTitleExists(titleName) && userDao.CheckIfUserExists(userName))
     {
         // default issue perod is 15 days
         rentalDao.AddRental(titleName, userName, noOfDaysToIssueFor == null ? 15 : noOfDaysToIssueFor);
     }
     else
     {
         // TODO
         // throw exceptions
     }
 }
Example #3
0
        public void AddToWishList(string userName, string bookName)
        {
            if (!userDao.CheckIfUserExists(userName))
            {
                //TODO
                return;
            }

            if (!bookDao.CheckIfBookTitleExists(bookName))
            {
                //TODO
                return;
            }

            if (userDao.CheckIfWishListEntryExists(userName, bookName))
            {
                //TODO
                return;
            }

            userDao.AddToWishList(userName, bookName);
        }