Пример #1
0
        public void MakeMenu()
        {
            Console.WriteLine("\n____1: Display all available pets \n____2: Delete a pet \n____3: Create a new pet \n____4: Search by type \n____5: Update a pet \n____6: Sort pets by price from lowest \n____7: Get 5 cheapest available pets");

            var selection = Convert.ToInt32(Console.ReadLine());

            switch (selection)
            {
            case 1:

                PrintList(_CandleService.ReadAllCandles());
                MakeMenu();
                break;

            case 2:
                int idForDelete = PrintFindCandleById();
                _CandleService.DeleteCandle(idForDelete);
                break;

            case 3:
                var name   = Question("name: ");
                var color  = Question("color: ");
                var scent  = Question("type: ");
                var price  = Question1("price: ");
                var candle = _CandleService.CreateCandle(name, color, scent, price);
                _CandleService.SaveCandle(candle);
                MakeMenu();
                break;

            case 4:

                Console.WriteLine("Enter scent to look for: ");
                var search        = Console.ReadLine();
                var candlesByType = _CandleService.SearchCandlesByScent(search);

                Console.ReadLine();
                Console.Clear();
                break;


            case 5:
                var idEdit     = PrintFindCandleById();
                var candleEdit = _CandleService.SearchById(idEdit);

                var newName  = Question("Name of Pet:");
                var newColor = Question("Color:");
                var newScent = Question("Scent:");

                var newPrice = Question1("Price:");

                _CandleService.UpdateCandle(new Candles()
                {
                    ID    = idEdit,
                    Name  = newName,
                    Color = newColor,
                    Scent = newScent,
                    Price = newPrice,
                });


                Console.WriteLine("Edit Done");
                Console.ReadLine();

                break;
                UpdateCandle();
                MakeMenu();
                break;
            }
        }
Пример #2
0
 public ActionResult <IEnumerable <Candles> > Get()
 {
     return(_candlesService.ReadAllCandles());
 }