public void RemoveFood(Food food) { FoodDeliveryContainer cont = null; if (FoodsContainer.Count > 0) { cont = FoodsContainer.FirstOrDefault(x => x.Food == food); } if (cont != null) { int pos = FoodsContainer.IndexOf(cont); int amoutn = cont.Amount; if (FoodsContainer[pos].Amount - 1 <= 0) { FoodsContainer.Remove(cont); } else { FoodsContainer.Remove(cont); FoodsContainer.Insert(pos, new FoodDeliveryContainer { Food = food, Amount = amoutn - 1 }); } SaveChangues(); } }
public void AddFood(Food food) { FoodDeliveryContainer cont = null; if (FoodsContainer.Count > 0) { cont = FoodsContainer.FirstOrDefault(x => x.Food == food); } if (cont != null) { int pos = FoodsContainer.IndexOf(cont); int amoutn = cont.Amount; FoodsContainer.Remove(cont); FoodsContainer.Insert(pos, new FoodDeliveryContainer { Food = food, Amount = amoutn + 1 }); } else { FoodsContainer.Add(new FoodDeliveryContainer { Food = food, Amount = 1 }); } SaveChangues(); // Foods = new ObservableCollection<FoodDeliveryContainer>(SharedData.actualDelivery.foods); }
public void RemoveFullFood(Food food) { FoodDeliveryContainer cont = null; if (FoodsContainer.Count > 0) { cont = FoodsContainer.FirstOrDefault(x => x.Food == food); } if (cont != null) { FoodsContainer.Remove(cont); SaveChangues(); } }