コード例 #1
0
 public List <ShoppingList> GetAllDataForShopping()
 {
     using (var db = new BearAndKitty())
     {
         var shoppingLists = (from s in db.ShoppingLists select s).ToList();
         return(shoppingLists);
     }
 }
コード例 #2
0
 public void DeleteItemFromShoppingList(int id)
 {
     using (var db = new BearAndKitty())
     {
         var shoppingListToRemove = (from s in db.ShoppingLists
                                     where s.Id == id
                                     select s).SingleOrDefault();
         db.ShoppingLists.Remove(shoppingListToRemove);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public void AddItemToShoppingList(string nameOfProduct, int amount = 1, string description = "")
 {
     using (var db = new BearAndKitty())
     {
         var shoppingList = new ShoppingList()
         {
             Amount        = amount,
             Description   = description,
             NameOfProduct = nameOfProduct
         };
         db.ShoppingLists.Add(shoppingList);
         db.SaveChanges();
     }
 }