//add shopping list public void AddShoppingList(ShoppingList newShoppingList) { toDoDB.MyShoppingList.InsertOnSubmit(newShoppingList); toDoDB.SubmitChanges(); AllShoppingList.Add(newShoppingList); //we need to update observable collection }
public void DeleteSHList(ShoppingList shlistForDelete) { // Remove the to-do item from the "all" observable collection. //AllToDoItems.Remove(toDoForDelete); AllShoppingList.Remove(shlistForDelete); // Remove the to-do item from the data context. toDoDB.MyShoppingList.DeleteOnSubmit(shlistForDelete); // Remove the to-do item from the appropriate category. //switch (toDoForDelete.Category.Name) //{ // case "Home": // HomeToDoItems.Remove(toDoForDelete); // break; // case "Work": // WorkToDoItems.Remove(toDoForDelete); // break; // case "Hobbies": // HobbiesToDoItems.Remove(toDoForDelete); // break; // default: // break; //} // Save changes to the database. toDoDB.SubmitChanges(); }
/// <summary> /// Constructor with the AllShoppingList info window opening /// </summary> /// <param name="allShoppingWindowOpen">opends the window</param> public AllShoppingListViewModel(AllShoppingList allShoppingWindowOpen) { allShoppingListWindow = allShoppingWindowOpen; bgWorker.DoWork += WorkerOnDoWork; bgWorker.WorkerReportsProgress = true; bgWorker.WorkerSupportsCancellation = true; bgWorker.ProgressChanged += WorkerOnProgressChanged; bgWorker.RunWorkerCompleted += WorkerOnRunWorkerCompleted; ProgressBarVisibility = Visibility.Collapsed; ButtonVisibility = Visibility.Visible; ShoppingBasketList = shoppingData.GetAllSelectedShoppingBasketItems(LoggedGuest.ID).ToList(); StorageList = storagedata.GetAllSelectedIngredientStorageItems(LoggedGuest.ID).ToList(); storagedata.OnNotification += storagedata.AddIngredientStorage; }