public void removeItemFromOrder(DataContainers.MenuItem iItem) { if (newOrderItems.ContainsKey(iItem.id)) { if (newOrderItems[iItem.id].amount == 1) { newOrderItems.Remove(iItem.id); } else { newOrderItems[iItem.id].amount -= 1; newOrderItems[iItem.id].price -= 1 * iItem.price; } float f = 0.00f; foreach (var item in newOrderItems.Values) { f += item.price; } OnSumUploaded?.Invoke(f); } }
public void addItemToOrder(DataContainers.MenuItem iItem) { if (newOrderItems.ContainsKey(iItem.id)) { newOrderItems[iItem.id].amount += 1; newOrderItems[iItem.id].price += 1 * iItem.price; } else { newOrderItems.Add(iItem.id, new DataContainers.OrderItem()); newOrderItems[iItem.id].amount = 1; newOrderItems[iItem.id].id = iItem.id; newOrderItems[iItem.id].price = 1 * iItem.price; newOrderItems[iItem.id].name = iItem.name; } float f = 0.00f; foreach (var item in newOrderItems.Values) { f += item.price; } OnSumUploaded?.Invoke(f); }