/// <summary> /// Replaces an old <c>Shop</c>-Object with a modified one. /// </summary> /// <param name="oldShop">The <c>Shop</c>-Object that should be replaced.</param> /// <param name="newShop">The <c>Shop</c>-Object that should be inserted into the Collection.</param> public void EditShop(Shop oldShop, Shop newShop) { // Get index of old object int idx = Shops.IndexOf(oldShop); // Clone ShoppingLists-List var templist = ShoppingLists.ToList(); // Query all shopping lists and update the Shop object of the Shopping lists foreach (ShoppingList list in templist) { if (list.Shop.ID.Equals(oldShop.ID)) { // Get index of old object int listIdx = ShoppingLists.IndexOf(list); // Set new shop list.Shop = newShop; // Remove old object from list and insert new one ShoppingLists.RemoveAt(listIdx); ShoppingLists.Insert(listIdx, list); } } // Remove old object and insert new object at the same position as the old one Shops.Remove(oldShop); Shops.Insert(idx, newShop); // Save data to isolated storage SaveShops(); SaveShoppingLists(); // Replace old Geofence with new one ServiceLocator.Current.GetInstance <GeoHelper>().ModifyGeofence(oldShop.ID, newShop); }
/// <summary> /// Method to invoke when the Edit command is executed. /// </summary> /// <param name="parameter">The parameter of the command.</param> private void OnEditExecute(object parameter) { var parameters = new Dictionary <string, object>(); parameters.Add("ShoppingListIndex", ShoppingLists.IndexOf(SelectedShoppingList)); _navigationService.Navigate <ShoppingListViewModel>(parameters); }
/// <summary> /// Called when the selected shopping list has changed. /// </summary> private void OnSelectedShoppingListChanged() { if (SelectedShoppingList != null) { var parameters = new Dictionary <string, object>(); parameters.Add("ShoppingListIndex", ShoppingLists.IndexOf(SelectedShoppingList)); _navigationService.Navigate <ShoppingListViewModel>(parameters); } }
/// <summary> /// Replaces an old <c>ShoppingList</c>-Object with a modified one. /// </summary> /// <param name="oldShoppingList">The <c>Shop</c>-Object that should be replaced.</param> /// <param name="newShoppingList">The <c>Shop</c>-Object that should be inserted into the Collection.</param> public void EditShoppingList(ShoppingList oldShoppingList, ShoppingList newShoppingList) { // Get index of old object int idx = ShoppingLists.IndexOf(oldShoppingList); // Remove old object and insert new object at the same position as the old one ShoppingLists.Remove(oldShoppingList); ShoppingLists.Insert(idx, newShoppingList); // Save data to isolated storage SaveShoppingLists(); }