public async Task AddBookToBookStoreAsync(BookStoreBook bookStoreBook) { using (var context = _dbContextFactoryMethod()) { context.BookStoresBooks.Add(bookStoreBook); await context.SaveChangesAsync(); } }
private void AddBookToBookStore() { var bookStoreBook = new BookStoreBook { BookId = _ioHelper.GetIntFromUser("Provide Book id"), BookStoreId = _ioHelper.GetIntFromUser("Provide BookStore id") }; _bookStoreService.AddBookToBookStoreAsync(bookStoreBook).Wait(); }
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); }
public async Task PostBookToBookStore([FromBody] BookStoreBook bookStoreBook) { await _bookStoreService.AddBookToBookStoreAsync(bookStoreBook); }