public override void AddIngridient() { List <Ingridient> ings = ingsRepo.GetIngs(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ings.Count; ++i) { sb.AppendLine("\n" + i + " - " + ings[i].Name + " price:" + ings[i].Price + " portion:" + ings[i].Portion); } sb.AppendLine("\n-1 - Next"); display.ShowInfo(sb.ToString()); int chooseIng = -1; do { chooseIng = -1; try { display.ShowInfo("\nAdd ingridient numb:"); int.TryParse(Console.ReadLine(), out chooseIng); if (chooseIng == -1) { return; } DrinkIngridient curIng = new DrinkIngridient(ings[chooseIng]); if (curIng != null) { int countIng; do { display.ShowInfo("Count:"); int.TryParse(Console.ReadLine(), out countIng); if (!curIng.HasPortions(countIng)) { display.ShowInfo("\nNot enough the ingridient"); Thread.Sleep(1000); AddIngridient(); } } while (countIng <= 0); curIng.SetCountPortion(countIng); newDrink.AddIngridient(curIng); display.ShowInfo("Added"); } } catch (Exception) { display.ShowInfo("\nWrong input"); } } while (chooseIng != -1); }
public virtual void AddIngridient(DrinkIngridient add) { ingridients.Add(add); }