Ejemplo n.º 1
0
        private void Add()
        {
            Console.Clear();

            Contact contact = new Contact();

            contact.ParentUserId = AuthenticationService.LoggedUser.Id;

            Console.WriteLine("Add new Contact:");
            Console.Write("Full Name: ");
            contact.FullName = Console.ReadLine();
            Console.Write("Email: ");
            contact.Email = Console.ReadLine();

            ContactsRepository contactsRepository = new ContactsRepository("contacts.txt");

            contactsRepository.Save(contact);

            Console.WriteLine("Contact saved successfully.");
            Console.ReadKey(true);

            PhonesManagerView phoneManagerView = new PhonesManagerView(contact);

            phoneManagerView.Show();
        }
Ejemplo n.º 2
0
        private void Update()
        {
            Console.Clear();

            Console.Write("Contact ID: ");
            int contactId = Convert.ToInt32(Console.ReadLine());

            ContactsRepository contactsRepository = new ContactsRepository("contacts.txt");
            Contact            contact            = contactsRepository.GetById(contactId);

            if (contact == null)
            {
                Console.Clear();
                Console.WriteLine("Contact not found.");
                Console.ReadKey(true);
                return;
            }

            Console.WriteLine("Editing Contact (" + contact.FullName + ")");
            Console.WriteLine("ID:" + contact.Id);

            Console.WriteLine("Name :" + contact.FullName);
            Console.Write("New Name:");
            string fullName = Console.ReadLine();

            Console.WriteLine("Email :" + contact.Email);
            Console.Write("New Email :");
            string email = Console.ReadLine();

            if (!string.IsNullOrEmpty(fullName))
            {
                contact.FullName = fullName;
            }
            if (!string.IsNullOrEmpty(email))
            {
                contact.Email = email;
            }

            contactsRepository.Save(contact);

            Console.WriteLine("Contact saved successfully.");
            Console.ReadKey(true);

            PhonesManagerView phoneManagerView = new PhonesManagerView(contact);

            phoneManagerView.Show();
        }
Ejemplo n.º 3
0
        private void View()
        {
            Console.Clear();

            Console.Write("Contact ID: ");
            int contactId = Convert.ToInt32(Console.ReadLine());

            ContactsRepository contactsRepository = new ContactsRepository("contacts.txt");
            PhonesRepository   phonesRepository   = new PhonesRepository("phones.txt");

            Contact contact = contactsRepository.GetById(contactId);

            if (contact == null)
            {
                Console.Clear();
                Console.WriteLine("Contact not found.");
                Console.ReadKey(true);
                return;
            }

            PhonesManagerView phonesManagerView = new PhonesManagerView(contact);

            phonesManagerView.Show();
        }