Example #1
0
        /// <summary>
        /// Method that finds book copies based on 3 criteria
        /// Listbox:
        ///     0 - Book title
        ///     1 - Author name
        /// And user input
        /// </summary>
        /// <param name="searchOption"></param>
        /// <param name="searchTerm"></param>
        private void FindBookBy(int searchOption, string searchTerm)
        {
            IEnumerable <BookCopy> bookCopies = bookCopyService.FindBookByAuthor(searchTerm);

            if (searchOption == 0)
            {
                bookCopies = bookCopyService.FindBookByTitle(searchTerm);
            }
            if (bookCopies.Count() > 0)
            {
                lbAvailCopies.Items.Clear();
                foreach (BookCopy bk in bookCopies)
                {
                    lbAvailCopies.Items.Add(bk);
                }
            }
            else
            {
                MessageBox.Show("No such books were found");
            }
        }