예제 #1
0
        private static void PrintPersonList(PersonManager personManager)//(string nome, string cognome, string birthday, int id)
        {
            //PersonManager personManager = new PersonManager();
            //List<Person> PersonList = new List<Person>();
            //Person user = new Person(nome, cognome, birthday, id);

            foreach (Person item in personManager.PersonList)
            {
                Console.WriteLine($"Le persone registrate sono: {item.Id}, {item.Nome}, {item.Cognome}, {item.Birthday} ");
            }

            return;
        }
예제 #2
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;
        }
예제 #3
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;
        }
예제 #4
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...");
        }