示例#1
0
        static void Main(string[] args)
        {
            GenresService  genresService = new GenresService();
            AuthorsService authorService = new AuthorsService();
            BooksService   booksService  = new BooksService();
            UserService    userService   = new UserService();

            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();
        }