public void CleanDatabase()
 {
     var db = new BookShopEntities();
     foreach (var lineItem in db.OrderLines)
     {
         db.DeleteObject(lineItem);
     }
     foreach (var order in db.Orders)
     {
         db.DeleteObject(order);
     }
     foreach (var book in db.Books)
     {
         db.DeleteObject(book);
     }
     db.SaveChanges();
 }
Beispiel #2
0
 public void GivenTheFollowingBooks(Table givenBooks)
 {
     var db = new BookShopEntities();
     foreach (var row in givenBooks.Rows)
     {
         Book book = new Book { Author = row["Author"], Title = row["Title"] };
         if (givenBooks.Header.Contains("Price"))
             book.Price = Convert.ToDecimal(row["Price"]);
         else
             book.Price = _bookDefaultPrice;
         if (givenBooks.Header.Contains("Id"))
             _catalogContext.ReferenceBooks.Add(row["Id"], book);
         else
             _catalogContext.ReferenceBooks.Add(book.Title, book);
         db.AddToBooks(book);
     }
     db.SaveChanges();
 }