Exemplo n.º 1
0
        /// <summary>
        /// Edits the contact list.
        /// </summary>
        /// <param name="contact">The contact.</param>
        /// <param name="choice">The choice.</param>
        public void EditContactList(AddressBookModel addressBookModel, int choice)
        {
            try
            {
                switch (choice)
                {
                case 1:
                    Console.WriteLine("Enter the first name");
                    string firstName = Console.ReadLine();
                    addressBookRegex.ValidateFirstName(firstName);
                    addressBookModel.FirstName = firstName;
                    break;

                case 2:
                    Console.WriteLine("Enter the last name");
                    string lastName = Console.ReadLine();
                    addressBookRegex.ValidateLastName(lastName);
                    addressBookModel.LastName = lastName;
                    break;

                case 3:
                    Console.WriteLine("Enter address");
                    string address = Console.ReadLine();
                    addressBookModel.Address = address;
                    break;

                case 4:
                    Console.WriteLine("Enter city");
                    string city = Console.ReadLine();
                    addressBookModel.City = city;
                    break;

                case 5:
                    Console.WriteLine("Enter state");
                    string state = Console.ReadLine();
                    addressBookModel.State = state;
                    break;

                case 6:
                    Console.WriteLine("Enter Phone Number");
                    string phoneNumber = Console.ReadLine();
                    addressBookRegex.ValidatePhoneNumber(phoneNumber);
                    addressBookModel.PhoneNumber = phoneNumber;
                    break;

                case 7:
                    Console.WriteLine("Enter Zip code");
                    string zipCode = Console.ReadLine();
                    addressBookRegex.ValidateZipCode(zipCode);
                    addressBookModel.ZipCode = zipCode;
                    break;

                case 8:
                    Console.WriteLine("Enter Email Id");
                    string eMailId = Console.ReadLine();
                    addressBookRegex.ValidateEmailId(eMailId);
                    addressBookModel.EmailID = eMailId;
                    break;

                default:
                    Console.WriteLine("Enter valid choice");
                    break;
                }
            }
            catch (AddressBookCustomException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }