Example #1
0
        private static void SetProductsParameters(out string modelName, out Instruments instrument, out int price, out Brands brand)
        {
            Chainer
            .RetrieveInput("Enter the model name: ", out modelName)
            .RetrieveInput("Enter product's price: ", out string priceString)

            .DisplayTextInColumn("Enter the brand name: ")
            .RetrieveInput($"\nAvailable brands: { string.Join(" / ", typeof(Brands).GetEnumNames())} ", out string brandString)

            .DisplayTextInColumn("Enter the instrument type: ")
            .RetrieveInput($"\nAvailable types: { string.Join(" / ", typeof(Instruments).GetEnumNames())} ", out string instrumentString);
            instrument = Chainer.ParseInputAsEnum <Instruments>(ref instrumentString);
            price      = Chainer.ParseInputAsInteger(ref priceString);
            brand      = Chainer.ParseInputAsEnum <Brands>(ref brandString);
        }
Example #2
0
        public UserInterface Run()
        {
            chainer.RetrieveInput("", out string input);
            int parsedInput = chainer.ParseInputAsInteger(ref input);

            switch (parsedInput)
            {
            case 1:
                if (!IsDisplayedSorted)
                {
                    database
                    .Clear()
                    .DisplaySorted();
                    IsDisplayedAlphabetically = false;
                    IsDisplayedSorted         = true;
                }
                else
                {
                    database
                    .Clear()
                    .DisplaySortedDescending();
                    IsDisplayedAlphabetically = false;
                    IsDisplayedSorted         = false;
                }
                break;

            case 2:
                if (!IsDisplayedAlphabetically)
                {
                    database
                    .Clear()
                    .DisplayAlphabetically();
                    IsDisplayedAlphabetically = true;
                    IsDisplayedSorted         = false;
                }
                else
                {
                    database
                    .Clear()
                    .DisplayAlphabeticallyDescending();
                    IsDisplayedAlphabetically = false;
                    IsDisplayedSorted         = false;
                }
                break;

            case 3:
                database
                .AddNewProduct()
                .Clear()
                .DisplayProducts()
                .SaveToFile();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;

            case 4:
                database
                .Clear()
                .DisplayProducts()
                .DeleteProduct()
                .SaveToFile()
                .Clear()
                .DisplayProducts();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;

            case 5:
                database
                .Clear()
                .DisplayProducts()
                .Reservation()
                .SaveToFile()
                .Clear()
                .DisplayProducts();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;

            case 6:
                database
                .Clear()
                .DisplayProducts()
                .DeleteReservation()
                .SaveToFile()
                .Clear()
                .DisplayProducts();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;

            case 7:
                database
                .Filter()
                .DisplayProducts();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;

            case 8:
                Environment.Exit(0);
                break;

            default:
                database
                .Clear()
                .DisplayProducts();
                IsDisplayedAlphabetically = false;
                IsDisplayedSorted         = false;
                break;
            }
            ControlPanel();
            Run();
            return(this);
        }