private void RemoveStockListItem(Item item) { var matchedItem = SalesSearchResults.FirstOrDefault(x => x.InventoryModel.InventoryId == item.InventoryModel.InventoryId); var itemIndex = SalesSearchResults.IndexOf(matchedItem); SalesSearchResults[itemIndex].InventoryModel.Quantity -= item.InventoryModel.Quantity; SalesSearchResults = new ObservableCollection <Item>(SalesSearchResults); }
private void ExecuteShoppingListCancelCommand() { var currentShoppingList = ShoppingList.ToList(); foreach (var item in currentShoppingList) { var matchedItem = SalesSearchResults.FirstOrDefault(x => x.InventoryModel.InventoryId == item.InventoryModel.InventoryId); var matchedItemIndex = SalesSearchResults.IndexOf(matchedItem); SalesSearchResults[matchedItemIndex].InventoryModel.Quantity += item.InventoryModel.Quantity; } SalesSearchResults = new ObservableCollection <Item>(SalesSearchResults); ShoppingList.Clear(); CalculateTotalPrice(); }