Пример #1
0
        public void TestDelete()
        {
            string terminalSerialNumber = "BB";

            InsertFake();

            var endpoint = _endpointService.Get(terminalSerialNumber);

            _endpointService.Delete(endpoint);
        }
Пример #2
0
        /// <summary>
        /// Formulário de Delete
        /// </summary>
        public static void FormDelete()
        {
            Console.WriteLine("\n----------------------------------------------------------------");
            Console.WriteLine("Gerenciador de Endpoints - Excluir\r");
            Console.WriteLine("----------------------------------------------------------------\n\n");

            Console.Write("Informe aqui o número de série do terminal que deseja excluir: ");

            var idTerminalSerialNumber = Console.ReadLine();

            var endpoint = _endpointService.Get(idTerminalSerialNumber);

            if (endpoint != null)
            {
                Console.WriteLine("\nSegue abaixo os detalhes do Endpoint\n");

                Console.WriteLine($"\tNúmero de série do terminal: {endpoint.TerminalSerialNumber}");
                Console.WriteLine($"\tModelo do medidor: {Helpers.GetMeterModelDescription(endpoint.IdMeterModel)}");
                Console.WriteLine($"\tNúmero do medidor: {endpoint.MeterNumber}");
                Console.WriteLine($"\tVersão do firmware do medidor: {endpoint.MeterFirmwareVersion}");
                Console.WriteLine($"\tMudança de estado: {Helpers.GetChangeStateDescription(endpoint.ChangeState)}");

                Console.WriteLine($"\nDeseja realmente excluir o registro '{endpoint.TerminalSerialNumber}'?\n");
                Console.WriteLine("\t1 - Sim");
                Console.WriteLine("\t2 - Não");

                Console.Write("\nInforme aqui o código da opção desejada: ");
                var option = Console.ReadLine();

                if (option.Equals("1"))
                {
                    _endpointService.Delete(endpoint);

                    Console.Clear();
                    Console.WriteLine("\n\n################################################################");
                    Console.WriteLine("Registro excluído com sucesso\r");
                    Console.WriteLine("################################################################");
                    ViewMenu.FormMenu();
                }
                else if (option.Equals("2"))
                {
                    Console.Clear();
                    ViewMenu.FormMenu();
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("\n################################################################");
                    Console.WriteLine("Opção inválida!\r");
                    Console.WriteLine("################################################################");
                    FormDelete();
                }
            }
            else
            {
                Console.WriteLine($"\nEndpoint '{idTerminalSerialNumber}' não encontrado!");
            }

            Console.WriteLine("\nPressione qualquer tecla para voltar ao menu!");

            Console.ReadKey();

            Console.Clear();
            ViewMenu.FormMenu();
        }