コード例 #1
0
        public void AddSushiOrNothing(SushiRepository sushis)
        {
            Console.WriteLine("Which sushi whoud you like to order?" +
                              "\nEnter the ID number + press 'ENTER' to add sushi \nPress 'ESCAPE' if you whoudn't add anything.");

            if (Console.ReadKey(true).Key != ConsoleKey.Escape)
            {
                int idSushiToOrder = Convert.ToInt32(Console.ReadLine());

                Sushi sushi     = sushis.GetSushiById(idSushiToOrder);
                Sushi tempSushi = new Sushi(sushi.Name, sushi.Weight, sushi.Cost, sushi.Things, sushi.HalfOrFull);
                tempSushi.Id = idSushiToOrder;

                MyLog.Logs("orderRepository.AddSushiInOrder started");

                orderRepository.AddSushiInOrder(tempSushi);
            }
        }
コード例 #2
0
        public void UpdateSushiInOrder(int id, SushiRepository sushis)
        {
            try
            {
                var sushi = sushiOrder.SingleOrDefault(item => item.Id == id);

                if (sushi == null)
                {
                    throw new NullReferenceException();
                }

                Sushi baseSushi = sushis.GetSushiById(sushi.Id);
                Sushi tempSushi = new Sushi(baseSushi.Name, baseSushi.Weight, baseSushi.Cost, baseSushi.Things, baseSushi.HalfOrFull);
                tempSushi.Id = sushi.Id;

                AddSushiInOrder(tempSushi);
            }
            catch (Exception ex)
            {
                Console.WriteLine("You don't have eny sushi whith this name in order!");

                MyLog.Logs($"Entered invalid sushi ID! Repiting going!\n{ex.Message}\n{ex.StackTrace}");
            }
        }