Пример #1
0
        public bool Contains(string text)
        {
            if (ReaderCard.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                CardNumber.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                Time.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            for (int i = 0; i < 3; i++)
            {
                if ((_tracks[i] != null) && _tracks[i].Contains(text))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        static void Main(string[] args)
        {
            /*Author markTven = new Author("Марк", "Твен", new DateTime(1835, 11, 30), Gender.MALE, "Aмериканский писатель, журналист и общественный деятель");
             * Console.WriteLine(markTven);
             *
             * foreach (string item in PaperStandarts.allFormats.Keys)
             * {
             *  Console.WriteLine(item);
             * }
             *
             * foreach (Size item in PaperStandarts.allFormats.Values)
             * {
             *  Console.WriteLine($"W: {item.Width}; H: {item.Height}");
             * }
             *
             * foreach (KeyValuePair<string, Size> item in PaperStandarts.allFormats)
             * {
             *  Console.WriteLine($"Format {item.Key}; Size: W {item.Value.Width}; H {item.Value.Height};");
             * }
             *
             * Console.WriteLine(PaperStandarts.getSize("A_0"));
             * Console.WriteLine(PaperStandarts.getPaperFormat("A_0"));
             *
             *
             * string pathToBook = Environment.CurrentDirectory + "\\" + "book_01.txt";
             * string[] bookRows = FileReader.ReadTxtFile(pathToBook);
             * Console.WriteLine("Колиество строк: " + bookRows.Length);
             * Console.ForegroundColor = ConsoleColor.Green;
             * Console.WriteLine(bookRows[0]);
             * Console.ResetColor();
             * Console.Read();*/


            /*Size sizePaper = PaperStandarts.getSize("A_4");
             * Console.WriteLine($"Height: {sizePaper.Height}; Width: {sizePaper.Width}. ");*/



            /*List<Page> allPages =
             * StorageReader.getPages(Environment.CurrentDirectory + "\\" + "book_01.txt", PaperStrogeStandarts.getPaperInfo("A_4"));
             *
             * Console.WriteLine(allPages[1].Text);*/


            string pathToBook = Environment.CurrentDirectory + "\\" + "book_01.txt";
            string shortDesc  = "современный российский писатель-фантаст. Родился в семье учителя и инженера. До четырнадцати лет жил в Киргизии. Потом переехал на Урал";

            Book book_01 = new Book(pathToBook, "Война и мир", Genres.DRAM, Langs.RU, "A_5", "Noname comp*", new DateTime(2019, 05, 05));

            book_01.Authors.Add(new Author("Лев", "Толстой", new DateTime(1980, 01, 01), Gender.MALE, shortDesc));

            Book book_02 = new Book(pathToBook, "Зиний вечер", Genres.LOVE_STORY, Langs.RU, "A_5", "Noname comp*", new DateTime(2019, 05, 05));

            book_02.Authors.Add(new Author("Александр", "Пушкин", new DateTime(1980, 01, 01), Gender.MALE, shortDesc));

            Book book_03 = new Book(pathToBook, "Мертвые души", Genres.DRAM, Langs.RU, "A_5", "Noname comp*", new DateTime(2019, 05, 05));

            book_03.Authors.Add(new Author("Николай", "Гоголь", new DateTime(1980, 01, 01), Gender.MALE, shortDesc));

            Book book_04 = new Book(pathToBook, "Мертвые души", Genres.DRAM, Langs.RU, "A_5", "Noname comp*", new DateTime(2019, 05, 05));

            book_04.Authors.Add(new Author("Кто то", "Неизвестный", new DateTime(1980, 01, 01), Gender.MALE, shortDesc));

            Library library = new Library();

            library.addBook(book_01);
            library.addBook(book_02);
            library.addBook(book_03);
            library.addBook(book_04);


            Console.WriteLine("-------------------------");
            Reader rdr = new Reader("Greg", "Shevchenko", new DateTime(1989, 12, 11), Gender.MALE, "*****@*****.**", "+380500745280", "38520 Dykanka", ReaderRate.Neutral);

            Console.WriteLine(rdr);
            Console.WriteLine("-------------------------");

            Book book_01_ref = library.getBook(book_01.Authors.First <Author>(), "Тайная жизнь города");

            Console.WriteLine(book_01_ref);

            Console.WriteLine("Нашли книгу: ");
            Console.WriteLine(library.getBook("Война и мир"));
            Console.WriteLine("Её жанр: ");
            Console.WriteLine(library.getBook("Война и мир").Genre);


            Console.WriteLine("Поиск нескольких книг по названию: ");
            Console.WriteLine("Найдено: " + library.getBooks("Мертвые души").Count + "книг");

            ReaderCard card = new ReaderCard(rdr);

            card.AddRecord(book_03);
            Console.WriteLine(card);

            card.DelRecord(book_03);
            Console.WriteLine(card);

            //Library - два метода
            //реализовать book=>Iprinted
            //generic collection
        }
Пример #3
0
 public void Update(ReaderCard entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }
Пример #4
0
 public void Insert(ReaderCard entity)
 {
     _context.Entry(entity).State = EntityState.Added;
     _context.SaveChanges();
 }
Пример #5
0
 public void Delete(ReaderCard entity)
 {
     _dbSet.Remove(entity);
     _context.SaveChanges();
 }
Пример #6
0
        public static void CreateData()
        {
            if (isCalled == true)
            {
                return;
            }

            ReaderCard readerCard1 = new ReaderCard
            {
                Id                 = 1,
                Name               = "Василій",
                Surname            = "Пупкін",
                Age                = 17,
                Email              = "*****@*****.**",
                DateOfRegistration = new DateTime(2018, 10, 2)
            };
            ReaderCard readerCard2 = new ReaderCard
            {
                Id                 = 2,
                Name               = "Анастасія",
                Surname            = "Козаченко",
                Age                = 19,
                Email              = "*****@*****.**",
                DateOfRegistration = new DateTime(2016, 3, 30)
            };
            ReaderCard readerCard3 = new ReaderCard
            {
                Id                 = 3,
                Name               = "Віталій",
                Surname            = "Дзюба",
                Age                = 24,
                Email              = "*****@*****.**",
                DateOfRegistration = new DateTime(2019, 4, 13)
            };

            Reader reader1 = new Reader()
            {
                Id = 1, ReaderCard = readerCard1
            };
            Reader reader2 = new Reader()
            {
                Id = 2, ReaderCard = readerCard2
            };
            Reader reader3 = new Reader()
            {
                Id = 3, ReaderCard = readerCard3
            };

            Book book1 = new Book()
            {
                Id = 1, Name = "Том в Гренландії"
            };
            Book book2 = new Book()
            {
                Id = 2, Name = "Філософія думок"
            };
            Book book3 = new Book()
            {
                Id = 3, Name = "Останній листок"
            };

            Record record1 = new Record
            {
                Id              = 1,
                Book            = book3,
                DateOfReceiving = new DateTime(2019, 10, 24),
                Reader          = reader1
            };
            Record record2 = new Record
            {
                Id              = 2,
                Book            = book1,
                DateOfReceiving = new DateTime(2020, 1, 16),
                Reader          = reader1
            };
            Record record3 = new Record
            {
                Id              = 3,
                Book            = book2,
                DateOfReceiving = new DateTime(2019, 5, 24),
                Reader          = reader2
            };
            Record record4 = new Record
            {
                Id              = 4,
                Book            = book3,
                DateOfReceiving = new DateTime(2019, 9, 4),
                Reader          = reader2
            };
            Record record5 = new Record
            {
                Id              = 5,
                Book            = book1,
                DateOfReceiving = new DateTime(2019, 6, 24),
                Reader          = reader3
            };

            reader1.Records.Add(record1);
            reader1.Records.Add(record2);
            reader2.Records.Add(record3);
            reader2.Records.Add(record4);
            reader3.Records.Add(record5);

            Chapter chapter1 = new Chapter()
            {
                Id = 1, Name = "Вступ", Book = book1
            };
            Chapter chapter2 = new Chapter()
            {
                Id = 2, Name = "Пригоди тома", Book = book1
            };
            Chapter chapter3 = new Chapter()
            {
                Id = 3, Name = "Завершення історії", Book = book1
            };
            Chapter chapter4 = new Chapter()
            {
                Id = 4, Name = "Усе починається з думки", Book = book2
            };
            Chapter chapter5 = new Chapter()
            {
                Id = 5, Name = "Думай серцем", Book = book2
            };
            Chapter chapter6 = new Chapter()
            {
                Id = 6, Name = "Холодна осінь", Book = book3
            };
            Chapter chapter7 = new Chapter()
            {
                Id = 7, Name = "Опале листя", Book = book3
            };

            book1.Chapters.Add(chapter1);
            book1.Chapters.Add(chapter2);
            book1.Chapters.Add(chapter3);
            book2.Chapters.Add(chapter4);
            book2.Chapters.Add(chapter5);
            book3.Chapters.Add(chapter6);
            book3.Chapters.Add(chapter7);

            Author author1 = new Author()
            {
                Id = 1, Name = "Георг", Surname = "Кельвінгтон", BirthDate = new DateTime(1965, 3, 25)
            };
            Author author2 = new Author()
            {
                Id = 2, Name = "Фрідріх", Surname = "Ніцше", BirthDate = new DateTime(1873, 6, 16)
            };
            Author author3 = new Author()
            {
                Id = 3, Name = "Себастьян", Surname = "Крудз", BirthDate = new DateTime(1983, 4, 11)
            };
            Author author4 = new Author()
            {
                Id = 4, Name = "Фредеріка", Surname = "Крудз", BirthDate = new DateTime(1878, 8, 3)
            };

            AuthorBook authorBook1 = new AuthorBook()
            {
                Id = 1, Author = author1, Book = book1
            };
            AuthorBook authorBook2 = new AuthorBook()
            {
                Id = 2, Author = author2, Book = book2
            };
            AuthorBook authorBook3 = new AuthorBook()
            {
                Id = 3, Author = author3, Book = book2
            };
            AuthorBook authorBook4 = new AuthorBook()
            {
                Id = 4, Author = author3, Book = book3
            };
            AuthorBook authorBook5 = new AuthorBook()
            {
                Id = 5, Author = author4, Book = book3
            };

            book1.AuthorBooks.Add(authorBook1);
            book2.AuthorBooks.Add(authorBook2);
            book2.AuthorBooks.Add(authorBook3);
            book3.AuthorBooks.Add(authorBook4);
            book3.AuthorBooks.Add(authorBook5);
            author1.AuthorBooks.Add(authorBook1);
            author2.AuthorBooks.Add(authorBook2);
            author3.AuthorBooks.Add(authorBook3);
            author3.AuthorBooks.Add(authorBook4);
            author4.AuthorBooks.Add(authorBook5);

            Readers.AddRange(new List <Reader>()
            {
                reader1, reader2, reader3
            });
            Books.AddRange(new List <Book>()
            {
                book1, book2, book3
            });
            Authors.AddRange(new List <Author>()
            {
                author1, author2, author3, author4
            });

            isCalled = true;
        }