コード例 #1
0
 public async Task AddBookToBookStoreAsync(BookStoreBook bookStoreBook)
 {
     using (var context = _dbContextFactoryMethod())
     {
         context.BookStoresBooks.Add(bookStoreBook);
         await context.SaveChangesAsync();
     }
 }
コード例 #2
0
        private void AddBookToBookStore()
        {
            var bookStoreBook = new BookStoreBook
            {
                BookId      = _ioHelper.GetIntFromUser("Provide Book id"),
                BookStoreId = _ioHelper.GetIntFromUser("Provide BookStore id")
            };

            _bookStoreService.AddBookToBookStoreAsync(bookStoreBook).Wait();
        }
コード例 #3
0
        public async Task <List <BookStoreBook> > DeserializeAsync(string path)
        {
            var serializedOfferLines = await File.ReadAllLinesAsync(path);

            var offer = new List <BookStoreBook>();

            foreach (var line in serializedOfferLines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                var data = line.Split(",");

                var bookStoreBook = new BookStoreBook
                {
                    Book = new Book
                    {
                        Title  = data[2],
                        Author = new Author
                        {
                            Name    = data[3],
                            Surname = data[4]
                        }
                    },
                    BookStore = new Bookstore
                    {
                        Name    = data[0],
                        Address = data[1]
                    }
                };

                offer.Add(bookStoreBook);
            }

            return(offer);
        }
コード例 #4
0
 public async Task PostBookToBookStore([FromBody] BookStoreBook bookStoreBook)
 {
     await _bookStoreService.AddBookToBookStoreAsync(bookStoreBook);
 }