예제 #1
0
        public void editBook(int id)
        {
            book = booksRepository.Find(id);

            //TODO. - inverter:
            //book.Category = txtCategory.Text;
            //book.Title = txtTitle.Text;
            //book.Price = Convert.ToDecimal(txtPrice.Text);
        }
예제 #2
0
        public static void UpdateBook()
        {
            HeaderMenu.Show();
            Console.WriteLine("You are at: > Books > Update book.");
            Console.WriteLine("");



            Console.Write("Type the ID of the book you want to update:");
            int  id   = Convert.ToInt32(Console.ReadLine());
            Book book = BooksRepository.Find(id);


            if (book != null)
            {
                Console.WriteLine($"You have selected: {book.Title}");
                Console.WriteLine("");

                Console.Write("Type the new title of the book you want to update:");
                book.Title = Console.ReadLine();
                Console.WriteLine("");

                Console.Write("Type the new price of the book you want to update:");
                book.Price = Convert.ToDecimal(Console.ReadLine());
                Console.WriteLine("");

                BooksRepository.Update(book);

                Console.WriteLine("");
                Console.WriteLine("Book updated successfully!");
                Console.WriteLine("");

                Console.WriteLine("Press any key to return.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Error. Invalid ID.");
                Console.WriteLine("Press any key to return.");
                Console.ReadKey();
                return;
            }
        }
예제 #3
0
        public void Find_Null_Test()
        {
            Book book = _repository.Find(100);

            Assert.IsNull(book);
        }