protected void addNewItem(Bill bill) { var item = new BillItem(); new ListArticles(displayHeader: false, waitInput: false).Run(); IOUtility.PrintSeparator(); ScrollToTop(); while (true) { var id = 0; var test = IOUtility.ReadInt(ConsoleMessages.READ_ARTICLE_ID, ref id); if (!test) { return; } try { var article = ArticleRepository.Instance.GetById(id); item.Article = article; break; } catch (ArgumentException e) { Console.WriteLine("Neispravan unos: " + e.Message); } } while (true) { try { if (item.Article.Type == ArticleType.Piecewise) { var quantity = 0; var test = IOUtility.ReadInt(ConsoleMessages.READ_QUANTITY, ref quantity); if (!test) { return; } item.Quantity = quantity; } else { var quantity = .0; var test = IOUtility.ReadDouble(ConsoleMessages.READ_QUANTITY, ref quantity, minValue: 0); item.Quantity = quantity; } break; } catch (ArgumentException e) { Console.WriteLine("Neispravan unos: " + e.Message); } } bill.AddItem(item); }
public void AddItem(BillItem item) { items.Add(item); }