Exemple #1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            CityRepository    c       = new CityRepository(context);
            CountryRepository country = new CountryRepository(context);
            AuthorRepository  a       = new AuthorRepository(context);
            GenreRepository   g       = new GenreRepository(context);
            BookRepository    books   = new BookRepository(context);

            Country coun = new Country("Российская Федерация");

            country.InsertObject(coun);
            country.Save();

            City city = new City("Москва", coun);

            c.InsertObject(city);
            c.Save();

            Publisher p = new Publisher("Nauka");

            p.City = city;
            context.Publishers.Add(p);
            context.SaveChanges();

            Genre genre = new Genre("Detective");

            g.InsertObject(genre);
            g.Save();

            Author au = new Author("Ivan4", "Ivanov", "Petrovich", DateTime.Parse("01.02.1980"), DateTime.Now, coun);

            a.InsertObject(au);
            a.Save();

            for (int i = 0; i < 3; i++)
            {
                Book b = new Book("Book" + i.ToString(), 4, au, p);
                b.Genre = genre;
                books.InsertObject(b);
                books.Save();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            GenreRepository  genreRepository  = new GenreRepository();
            BookRepository   bookRepository   = new BookRepository();
            AuthorRepository authorRepository = new AuthorRepository();
            GenresService    genresService    = new GenresService();
            AuthorsService   authorService    = new AuthorsService();
            BooksService     booksService     = new BooksService();
            UserService      userService      = new UserService();

            List <Genre> genres  = genreRepository.GetAll();
            var          books   = bookRepository.GetAll();
            var          book    = bookRepository.Get(1);
            var          authors = authorRepository.GetAll();

            //var authors = new List<AuthorDTO>();
            //authors.Add(authorService.FindById(1));
            //authors.Add(authorService.FindById(2));
            //var book = new BookDTO
            //{
            //    Title = "Book1",
            //    Pages = 100,
            //    Description = "New Book 1",
            //    Genre = genresService.FindById(2),
            //    Authors = authors
            //};
            //var list = book.Authors.Select(a => new { authorId = a.Id, bookId = 1 }).ToList();
            //booksService.Create(new BookDTO
            //{
            //    Title = "Book1",
            //    Pages = 100,
            //    Description = "New Book 1",
            //    Genre = genresService.FindById(2),
            //    Authors = authors
            //});

            //authorService.Create(new AuthorDTO
            //{
            //    FirstName = "Petya",
            //    LastName = "Ivanov",
            //    Birth = DateTime.Parse("2010-01-01")
            //});

            //AuthorDTO author = authorService.FindById(1);
            //List<AuthorDTO> authors = authorService.GetAll();

            //userService.Create(new UserDTO
            //{
            //    Login = "******",
            //    Password = "******",
            //    Email = "*****@*****.**"
            //});

            //UserDTO author = userService.FindById(1);
            //List<UserDTO> authors = userService.GetAll();


            //genresService.Delete(1);
            //GenreDTO genre = genresService.FindById(1);
            //List<GenreDTO> genres = genresService.GetAll();
            ;

            //WeatherAPIService weatherAPIService = new WeatherAPIService();
            //var weather = weatherAPIService.GetWeatherForCity("Dnepropetrovsk");

            //genresService.CreateGenre(new GenreDTO { Name = "Some genre" });
            //var genres = genresService.GetAllGenres();

            //genresService.CreateGenre(new GenreDTO { Name = "" });

            Console.Read();
        }