Пример #1
0
 public void AddBook(LibraryModel.Book b)
 {
     using (SqlConn)
     {
         using (SqlDataAdapter SqlAdapter = new SqlDataAdapter("insert into Book values ('" + b.getTitle() + "','" + b.getAuthor() + "','" + b.getLibrary() + "')", SqlConn))
         {
             DataTable table = new DataTable();
             SqlAdapter.Fill(table);
         }
     }
 }
Пример #2
0
 public bool Add(LibraryModel.Book book)
 {
     return(base.Channel.Add(book));
 }
Пример #3
0
 public bool Update(ref LibraryModel.Book book)
 {
     return(base.Channel.Update(ref book));
 }
Пример #4
0
 public bool Read(out LibraryModel.Book book, string key)
 {
     return(base.Channel.Read(out book, key));
 }
Пример #5
0
 public void addBook(LibraryModel.Book b)
 {
     LibraryRepository.Library repo = new LibraryRepository.Library();
     repo.AddBook(b);
 }
Пример #6
0
        static void Main(string[] args)
        {
            LibraryService.LibraryService l = new LibraryService.LibraryService();
            string ch = "0";

            Console.WriteLine("----------------------------MENU-----------------------------------------");
            Console.WriteLine("1.Add library");
            Console.WriteLine("2.See all libraries");
            Console.WriteLine("3.Add book");
            Console.WriteLine("4.See all books in a library");
            Console.WriteLine("Option:");
            ch = Console.ReadLine();
            while (!ch.Equals("0"))
            {
                switch (ch)
                {
                case "1":   Console.WriteLine("Library name:");
                    string name = Console.ReadLine();
                    Console.WriteLine("Library city:");
                    string city = Console.ReadLine();
                    LibraryModel.Library lib = new LibraryModel.Library(name, city);
                    l.insertLibrary(lib);
                    Console.WriteLine("Library added");
                    break;

                case "2":   Console.WriteLine("Library list:");
                    List <string> list = l.allLibraries();
                    Console.WriteLine("NAME          ||         CITY");
                    for (int i = 0; i < list.Count; i += 2)
                    {
                        Console.WriteLine(list.ElementAt(i) + "  ||  " + list.ElementAt(i + 1));
                    }
                    break;

                case "3":
                    Console.WriteLine("Book title:");
                    string title = Console.ReadLine();
                    Console.WriteLine("Book author:");
                    string author = Console.ReadLine();
                    Console.WriteLine("Book library:");
                    string            library = Console.ReadLine();
                    LibraryModel.Book book    = new LibraryModel.Book(title, author, library);
                    l.addBook(book);
                    Console.WriteLine("Book added");
                    break;

                case "4":
                    Console.WriteLine("Choose library:");
                    string libr = Console.ReadLine();
                    Console.WriteLine("Book list:");
                    Console.WriteLine("TITLE      ||     AUTHOR     ||       LIBRARY");

                    List <string> listbooks = l.allBooks(libr);
                    for (int i = 0; i < listbooks.Count; i += 3)
                    {
                        Console.WriteLine(listbooks.ElementAt(i) + "  ||  " + listbooks.ElementAt(i + 1) + "  ||  " + listbooks.ElementAt(i + 2));
                    }
                    break;

                case "0":   break;
                }
                Console.WriteLine("----------------------------MENU-----------------------------------------");
                Console.WriteLine("0.Exit");
                Console.WriteLine("1.Add library");
                Console.WriteLine("2.See all libraries");
                Console.WriteLine("3.Add book");
                Console.WriteLine("4.See all books in a library");
                Console.WriteLine("Option:");
                ch = Console.ReadLine();
            }
        }