Exemple #1
0
        /// <summary>
        /// Edits the details.
        /// </summary>
        /// <param name="bookName">Name of the book.</param>
        public static void EditDetails(string bookName)
        {
            int    option     = 0;
            string nameToEdit = string.Empty;

            Console.WriteLine("Enter the First Name you want to edit");
            nameToEdit = Console.ReadLine();

            if (AddressBookModelClass.DoesNameExist(nameToEdit, bookName) == false)
            {
                Console.WriteLine("The Name You Entered Does not Exist");
                return;
            }

            Console.WriteLine("------------------------------------------");
            AddressBook.PrintSingleAddresss(bookName, nameToEdit);
            Console.WriteLine("------------------------------------------");

            while (true)
            {
                Console.WriteLine("Choose what you want to edit");
                Console.WriteLine("0) To Go back");
                Console.WriteLine("1) Address");
                Console.WriteLine("2) City");
                Console.WriteLine("3) State");
                Console.WriteLine("4) Zip");
                Console.WriteLine("5) PhoneNumber");
                string stringOption = Console.ReadLine();

                if (InventoryManagementProgram.Utility.IsNumber(stringOption) == false)
                {
                    Console.WriteLine("Invalid Input");
                    continue;
                }

                option = Convert.ToInt32(stringOption);

                ////calling the methods based on the Option Choosen.
                switch (option)
                {
                case 0:
                {
                    return;
                }

                case 1:
                {
                    AddressDetailsManipulation.ChangeAddress(bookName, nameToEdit);
                    break;
                }

                case 2:
                {
                    AddressDetailsManipulation.ChangeCity(bookName, nameToEdit);
                    break;
                }

                case 3:
                {
                    AddressDetailsManipulation.ChangeState(bookName, nameToEdit);
                    break;
                }

                case 4:
                {
                    AddressDetailsManipulation.ChangeZip(bookName, nameToEdit);
                    break;
                }

                case 5:
                {
                    AddressDetailsManipulation.ChangePhoneNumber(bookName, nameToEdit);
                    break;
                }

                default:
                {
                    Console.WriteLine("Invalid Input");
                    break;
                }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Takes the input for address.
        /// </summary>
        /// <param name="bookName">Name of the book.</param>
        public static void TakeInputForAddress(string bookName)
        {
            string firstName   = string.Empty;
            string lastName    = string.Empty;
            string address     = string.Empty;
            string city        = string.Empty;
            string state       = string.Empty;
            string zip         = string.Empty;
            string phoneNumber = string.Empty;

            while (true)
            {
                Console.WriteLine("Enter the firstName");
                firstName = Console.ReadLine();

                if (!Regex.IsMatch(firstName, "^[a-zA-z]+$"))
                {
                    Console.WriteLine("Wrong input,(Characters,number not allowed)");
                    continue;
                }

                if (AddressBookModelClass.DoesNameExist(bookName, firstName))
                {
                    Console.WriteLine("First name with" + firstName + " Already exist, please enter another name");
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the LastName");
                lastName = Console.ReadLine();

                if (!Regex.IsMatch(lastName, "^[a-zA-z]+$"))
                {
                    Console.WriteLine("Wrong input,(Characters,number not allowed)");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the Address");
                address = Console.ReadLine();

                if (Utility.CheckString(address))
                {
                    Console.WriteLine("Address Cant be Empty");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the City");
                city = Console.ReadLine();

                if (!Regex.IsMatch(city, "^[a-zA-z]+$"))
                {
                    Console.WriteLine("Wrong input,(Characters,number not allowed)");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the State");
                state = Console.ReadLine();

                if (!Regex.IsMatch(state, "^[a-zA-z]+$"))
                {
                    Console.WriteLine("Wrong input,(Characters,number not allowed)");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the Zip");
                zip = Console.ReadLine();

                if (!Regex.IsMatch(zip, "^[0-9]+$"))
                {
                    Console.WriteLine("Wrong input,(Characters not allowed)");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the phoneNumber");
                phoneNumber = Console.ReadLine();

                if (!Regex.IsMatch(phoneNumber, "^[0-9]{10}$"))
                {
                    Console.WriteLine("Wrong input,(Characters,number not allowed)");
                    continue;
                }

                break;
            }

            AddressBookModelClass.CreateAddressDetails(bookName, firstName, lastName, address, city, state, zip, phoneNumber);
        }