Beispiel #1
0
        public void GetBookShelf()
        {
            var book = new BookShelfContext();

            foreach (var c in book.Characters)
            {
                Console.WriteLine($"Id: {c.Id},  \tFirstName: {c.FirstName}  " +
                                  $"\tLastName: {c.LastName}    \tGender: {c.Gender}  \tAge: {c.Age}");
            }
        }
Beispiel #2
0
        public void AddBookShelf()
        {
            var book       = new BookShelfContext();
            var characters = CinemaService.GetCharacters();

            foreach (var charactert in characters)
            {
                book.Characters.Add(charactert);
            }
            book.SaveChanges();
        }
Beispiel #3
0
        public void AddMovies()
        {
            var book = new BookShelfContext();

            var movie = new Movie()
            {
                Id = 1, Name = "Star Wars", Genre = "science fiction", Year = 1999
            };

            book.Movies.Add(movie);
            book.SaveChanges();
            Console.WriteLine($"Movie: {movie.Name} added");
        }
Beispiel #4
0
        public void AddCharacterBookShelf()
        {
            var book         = new BookShelfContext();
            var characterOne = new Character()
            {
                FirstName = "Dale", LastName = "Cooper", Gender = true, Age = 27
            };
            var characterTwo = new Character()
            {
                FirstName = "Laura", LastName = "Palmer", Gender = true, Age = 19
            };

            book.Characters.AddRange(new Character[] { characterOne, characterTwo });
            book.SaveChanges();
            Console.WriteLine($"Characters {characterOne.FirstName},{characterTwo.FirstName} added");
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            using (BookShelfContext book = new BookShelfContext())
            {
                var character = new Character();
                //Добавление в БД модели персонажей
                book.Characters.Add(character);

                var bookService = new BookShelfService();

                //Вызов метода заполнения таблицы персонажами
                bookService.AddCharacterBookShelf();

                //Вывод персонажей в консоль
                bookService.GetBookShelf();

                //Вставка записи в таблицу Movies
                bookService.AddMovies();
            }
        }