public void Mark(bool isMarked, long isbn) { var book = dbContext.Books.SingleOrDefault(b => b.Isbn == isbn); if (book == null) { throw new Exception("Can't find a book with ISBN = " + isbn); } book.IsMakred = isMarked; dbContext.Entry(book).State = EntityState.Modified; dbContext.SaveChanges(); }
private void LoadBooks(string isbns) { var newRecords = new List <Book>(); var isbnList = isbns.Split(' '); foreach (var isbn in isbnList) { LoadBook(isbn, newRecords); } if (newRecords.Count > 0) { dbContext.Books.AddRange(newRecords); dbContext.SaveChanges(); } }