Пример #1
0
        private static void DelDataPerson(PersonManager personManager)
        {
            MonitorConsole.PrintRemoveIdRequest();
            string _id = Console.ReadLine();
            int    id;

            int.TryParse(_id, out id);
            string nome     = string.Empty;
            string cognome  = string.Empty;
            string birthday = string.Empty;

            personManager.DelPerson(nome, cognome, birthday, id);
            return;
        }
Пример #2
0
        //internal void ConsoleInput()
        //{
        //    Console.WriteLine("");
        //    Console.WriteLine("Menu Inserimento dati");
        //    Console.WriteLine("[1] Aggiungi Nuova Persona");
        //    Console.WriteLine("[2] Rimuovi Persona esistente");
        //    Console.WriteLine("[3] Stampa elenco di persone");
        //    Console.WriteLine("[4] Esci dal programma");

        //}

        internal static void AddDataPerson(PersonManager personManager, int id)
        {
            //PersonManager personManager = new PersonManager();
            MonitorConsole.PrintNameRequest();
            string nome = Console.ReadLine();

            MonitorConsole.PrintSurnameRequest();
            string cognome = Console.ReadLine();

            MonitorConsole.PrintBirtdayRequest();
            string birthday = Console.ReadLine();
            int    _id;

            _id = id + 1;

            personManager.AddPerson(nome, cognome, birthday, _id);
            MonitorConsole.PersonAdded();
            return;
        }
Пример #3
0
        static void Main(string[] args)
        {
            bool          memory;
            bool          loop = false;
            PersonManager personManager;

            MonitorConsole.PrintMemoryChoise();
            string input = Console.ReadLine();

            if (input == "r")
            {
                try
                {
                    personManager = new PersonManager(new MemoryStorage());
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"eccezione in add person in memoria {ex.Message} {ex.GetType()}");
                    throw;
                }//tryc
            }
            else
            {
                try
                {
                    personManager = new PersonManager(new FileStorage());
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"eccezione in add person su file {ex.Message} {ex.GetType}");
                    throw;
                } //tryc
            }     //endif

            if (input == "r")
            {
                memory = false;
            }
            if (input == "d")
            {
                memory = true;
            }
            Console.WriteLine("Impostazioni salvate");
            loop = true;
            int id = 0;

            while (loop)
            {
                MonitorConsole.PrintMenu();
                input = Console.ReadLine();
                List <Person> PersonList = new List <Person>();
                UserInput     result     = GetInput(input);
                //PersonManager personManager = new PersonManager();

                if (result == UserInput.Exit)
                {
                    break;
                }
                if (result == UserInput.AddPerson)
                {
                    AddDataPerson(personManager, id);
                }
                if (result == UserInput.DelPerson)
                {
                    DelDataPerson(personManager);
                }
                if (result == UserInput.PrintPersons)
                {
                    PrintPersonList(personManager);
                }
                if (result == UserInput.Error)
                {
                    Console.WriteLine("Attenzione il comando inserito non corrisponde ad un numero");
                }
            }
            Console.WriteLine("Uscita in corso...");
        }