예제 #1
0
 public void getRemove()
 {
     using (var bookRem = new BookContext())
     {
         Console.WriteLine("Type the id of the book you would like to remove:");
         CurrentBooks bRem = new CurrentBooks()
         {
             Id = Int32.Parse(Console.ReadLine())
         };
         bookRem.CurrentBooks.Remove(bRem);
         Console.WriteLine("Press enter to save changes.");
         Console.ReadLine();
         bookRem.SaveChanges();
         Console.WriteLine("The book has been deleted from the database!");
     }
 }
예제 #2
0
        public void AddCompleteBooks()
        {
            using (var bookC = new BookContext())
            {
                Console.WriteLine("Add the book you just finished by typing: BookName, BookAuthor and sumary");
                CurrentBooks b = new CurrentBooks()
                {
                    BookName   = Console.ReadLine(),
                    BookAuthor = Console.ReadLine(),
                    BookSumary = Console.ReadLine()
                };

                bookC.CurrentBooks.Add(b);
                Console.WriteLine("Press enter to save changes.");
                Console.ReadLine();
                bookC.SaveChanges();
                Console.WriteLine("The book has been saved in the database!");
            }
        }