/// <summary> /// добавление блюда во внутренний список заказа /// </summary> /// <param name="dish"></param> /// <param name="price"></param> public void addDishToOrder() { int index = view.getIndexSelectedDish(); bool nothing = true; foreach (int i in Enumerable.Range(0, currentOrder.Count)) { if (currentOrder[i].id == currentMenu[dishindex].id) { OrderEntry temp = new OrderEntry(currentOrder[i]); temp.inreament(); currentOrder[i] = temp; nothing = false; ; } } if (nothing) currentOrder.Add(currentMenu[dishindex].ToOrderEntry()); updateDishPhoto(); //void setDishPhoto(String path) }
//конструктор копии public OrderEntry(OrderEntry entry) { this.dish = entry.Dish; this.count = entry.Count; this.price = entry.price; this.id = entry.id; this.linkToPhoto = entry.linkToPhoto; }
/// <summary> /// удаление блюда из внутреннего списка меню /// </summary> /// <param name="dish"></param> /// <param name="price"></param> public void removeDishFromOrder() { int index = findDishOrder(orderDiahNameCrutch); OrderEntry temp = new OrderEntry(currentOrder[index]); if (temp.Count == 1) currentOrder.Remove(temp); else { temp.decreament(); currentOrder[index] = temp; } return; }
public bool Equals(OrderEntry other) { if (this.id != other.id || this.count != other.count || this.price != other.price || this.dish!=other.dish) return false; else return true; }