コード例 #1
0
ファイル: EndpointConsole.cs プロジェクト: CortezzZ007/Landis
        public void SearchEndpoint()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("Search for an endpoint");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint you want to find and press enter: ", this.error);

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.SearchEndpoint();
            }

            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);
            this.BackMenuInitial();
        }
コード例 #2
0
ファイル: EndpointConsole.cs プロジェクト: CortezzZ007/Landis
        public void Edit()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint you want to edit and press enter: ", this.error);

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.Edit();
            }
            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);

            var chosenItem = customInputValidation.GetInteger("\nDo you want to change the endpoint state?\n1- Yes\n2- No\nType the desired option and press enter:  ", this.error);

            if (chosenItem == 1)
            {
                Console.WriteLine("\nStarting endpoint editing.");
                Console.WriteLine("\nChoose which state the endpoint is in: ");
                Console.WriteLine("1- Disconnected");
                Console.WriteLine("2- Connected");
                Console.WriteLine("3- Armed");

                endpointDto.State = customInputValidation.GetInteger("Type the option of your choice and press enter: ", this.error);

                while (!(endpointDto.State == 1 || endpointDto.State == 2 || endpointDto.State == 3))
                {
                    Console.WriteLine("Option invalid.");
                    endpointDto.State = customInputValidation.GetInteger("Type the option of your choice and press enter: ", this.error);
                }

                this.editStateEndpoint.Execute(endpointDto.SerialNumber, endpointDto.State);
                if (editStateEndpoint.Error.Count > 0)
                {
                    Console.WriteLine(editStateEndpoint.Error.First());
                }
                else
                {
                    Console.WriteLine("\nFinished editing");
                    Console.WriteLine(sucess);
                }
            }

            this.BackMenuInitial();
        }
コード例 #3
0
ファイル: EndpointConsole.cs プロジェクト: CortezzZ007/Landis
        public void Delete()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("\nDelete Endpoint");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint you want to delete and press enter: ", this.error);

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.Delete();
            }
            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);

            var chosenItem = customInputValidation.GetInteger("\nDo you really want to delete this endpoint?\n1- Yes\n2- No\nType the desired option and press enter: ", this.error);

            while (!(chosenItem == 1 || chosenItem == 2))
            {
                chosenItem = customInputValidation.GetInteger("\nDo you really want to delete this endpoint?\n1- Yes\n2- No\nType the desired option and press enter: ", this.error);
            }
            if (chosenItem == 1)
            {
                this.deleteEndpoint.Execute(endpointDto.SerialNumber);
                if (this.deleteEndpoint.Error.Count > 0)
                {
                    Console.WriteLine(this.searchBySerialNumber.Error.First());
                    this.Delete();
                }
                Console.WriteLine("\n" + sucess);
            }
            this.BackMenuInitial();
        }