Esempio n. 1
0
        static void Update()
        {
            // view
            int id = 0;

            do
            {
                Console.Clear();
                Console.Write("Please eneter the Id of a person to Update: ");
            }while(!int.TryParse(Console.ReadLine(), out id));

            IDataMapper <Person> dalPerson = new PersonFileDataMapper();
            Person person = dalPerson.Get(id);

            Console.Write("Please enter Name ({0}): ", person.Name);
            person.Name = Console.ReadLine();
            Console.Write("Family Name ({0}): ", person.FamilyName);
            person.FamilyName = Console.ReadLine();
            Console.Write("Birthdate ({0}): ", person.BirthDate.ToString("yyyy-MM-dd"));
            CultureInfo provider = CultureInfo.InvariantCulture;

            // provider = new CultureInfo("fr-FR");
            person.BirthDate = DateTime.ParseExact(Console.ReadLine(), "yyyy-MM-dd", provider);
            Console.Write("Address ({0}): ", person.Address);
            person.Address = Console.ReadLine();

            // Controller
            dalPerson.Update(person);
        }
Esempio n. 2
0
        static void Delete()
        {
            // view
            int id = 0;

            do
            {
                Console.Clear();
                Console.Write("Please eneter the Id of a person to Update: ");
            } while (!int.TryParse(Console.ReadLine(), out id));

            IDataMapper <Person> dalPerson = new PersonFileDataMapper();
            var person = dalPerson.Get(id);

            dalPerson.Delete(person);
        }