public static void Main(string[] args) { var bookStorage = new BookListStorage(@"H:\BookStorage.txt"); var bookService = new BookListService(bookStorage); var newBook = new Book() { Author = "Author", Cost = 20, ISBN = "346632436562", Name = "Book name", PagesNumber = 246, PublicationYear = 2000, Publisher = "Publisher name" }; Console.WriteLine(bookService.AddBook(newBook)); var booksList = bookService.GetAllBooks(); newBook = new Book() { Author = "Author2", Cost = 20, ISBN = "123632436562", Name = "Book name 2", PagesNumber = 246, PublicationYear = 2000, Publisher = "Publisher name 2" }; Console.WriteLine(bookService.AddBook(newBook)); booksList = bookService.SortBooksByTag(SearchTags.ISBN); var searchingResult = bookService.FindBooksByTag(SearchTags.ISBN, "123632436562"); var bankAccountStorage = new BankAccountsRepository(@"H:\BankAccountStorage.txt"); var bankAccountService = new BankAccountService(bankAccountStorage); var newBankAccount = new BankAccount(1, "FirstName", "LastName", 20, 0, false, BankAccountTypes.Standart, 10); Console.WriteLine(bankAccountService.AddAccount(newBankAccount)); newBankAccount = new BankAccount(2, "FirstName2", "LastName2", 22, 3, false, BankAccountTypes.Gold, 20); Console.WriteLine(bankAccountService.AddAccount(newBankAccount)); var bankAccountsList = bankAccountService.GetAllBankAccounts(); bankAccountService.TopUpInAnAccount(30, bankAccountsList.ToList()[0].AccountId); bankAccountService.DebitTheAccount(10, bankAccountsList.ToList()[1].AccountId); Console.ReadKey(); }
/// <summary> /// Main method of the console application. /// </summary> /// <param name="args"> /// Passed parameters. /// </param> public static void Main(string[] args) { Book a = new Book("1-56389-668-0", "A", "B", "C", 1999, 123, 12); Book b = new Book("5-12231-234-9", "B", "C", "A", 1990, 453, 30); Book c = new Book("6-12331-454-2", "C", "A", "B", 2018, 381, 15); BinaryBookListStorage binaryBookListStorage = new BinaryBookListStorage(StoragePath); BookListService bookListService = new BookListService(binaryBookListStorage, new NLogger()); bookListService.AddBook(a); bookListService.AddBook(b); bookListService.AddBook(c); bookListService.SaveBooksToStorage(); bookListService.SortBooksByTag(new TitleBookSorting()); bookListService.SortBooksByTag(new AuthorBookSorting()); bookListService.SortBooksByTag(new YearBookDescendingSorting()); var titleResult = bookListService.FindBooksByTag(new TitleBookFinder("A")); var authorResult = bookListService.FindBooksByTag(new AuthorBookFinder("B")); }
private static void FindTagsMenu() { OutTagsMenu("Find"); string tag = Console.ReadLine(); switch (tag) { case "1": Console.WriteLine("Enter author"); string author = Console.ReadLine(); PrintBooks(service.FindBooksByTag(b => b.Authors.Contains(author))); break; case "2": Console.WriteLine("Enter title"); string title = Console.ReadLine(); PrintBooks(service.FindBooksByTag(b => b.Title == title)); break; case "3": Console.WriteLine("Enter publisher"); string publisher = Console.ReadLine(); PrintBooks(service.FindBooksByTag(b => b.Publisher == publisher)); break; case "4": Console.WriteLine("Enter year of publishing"); int year = int.Parse(Console.ReadLine()); PrintBooks(service.FindBooksByTag(b => b.PublishingYear == year)); break; case "0": MainMenu(); break; default: Console.WriteLine("Invalid command"); break; } }
static void Main(string[] args) { var service = new BookListService(BookListStorage.Instance); service.Save(); var books = new Book[9]; books[0] = new Book("1234567890121", "Author1", "Title1", "Publisher1", 1, 1, 1); books[1] = new Book("1234567890122", "Author2", "Title2", "Publisher1", 1, 1, 1); books[2] = new Book("1234567890123", "Author3", "Title3", "Publisher2", 1, 1, 1); books[3] = new Book("1234567890124", "Author1", "Title4", "Publisher2", 1, 1, 1); books[4] = new Book("1234567890125", "Author2", "Title5", "Publisher3", 1, 1, 1); books[5] = new Book("1234567890126", "Author3", "Title6", "Publisher3", 1, 1, 1); books[6] = new Book("1234567890127", "Author4", "Title1", "Publisher4", 1, 1, 1); books[7] = new Book("1234567890128", "Author1", "Title2", "Publisher4", 1, 1, 1); books[8] = new Book("1234567890129", "Author5", "Title3", "Publisher4", 1, 1, 1); foreach (var book in books) { service.AddBook(book); } service.Save(); var newService = new BookListService(BookListStorage.Instance); foreach (var item in newService.Load().FindBooksByTag(books[1], Book.Tag.ISBN)) { Console.WriteLine(item.ToString("isbn, author", null)); } Console.WriteLine("----------------------------------------"); foreach (var item in newService.FindBooksByTag(books[1], Book.Tag.Author)) { Console.WriteLine(item.ToString("isbn, author", null)); } Console.WriteLine("----------------------------------------"); for (int i = 0; i < newService.CountOfBooks; i++) { Console.WriteLine(newService[i].ToString("isbn, author, title", null)); } Console.WriteLine("---------------------------------------"); newService.SortBooksByTag(Book.Tag.Author); var bookFormatter = new BookFormatter(); for (int i = 0; i < newService.CountOfBooks; i++) { Console.WriteLine(bookFormatter.Format("full", newService[i], null)); } newService.Save(); foreach (var book in books) { newService.RemoveBook(book); } }