Example #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 (AddressDetails.DoesFileNameExist(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 (InventoryManagement.InventoryMngtUtility.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;
                }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Address book the view.
        /// </summary>
        /// <param name="bookName">Name of the book.</param>
        public static void AddressbookView(string bookName)
        {
            int option = 0;

            while (true)
            {
                Console.WriteLine("Choose what you want to do with AdressBook " + bookName + ".");
                Console.WriteLine("Press 0) To Go Back");
                Console.WriteLine("press 1) To Open the BookDetails");
                Console.WriteLine("Press 2) To Add Address");
                Console.WriteLine("Press 3) To Edit an Address");
                Console.WriteLine("Press 4) To Sort the " + bookName + " book details By Last Name");
                Console.WriteLine("Press 5) To Sort the " + bookName + " book details By Zip");

                string stringOption = Console.ReadLine();

                try
                {
                    option = Convert.ToInt32(stringOption);
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Input");
                    continue;
                }

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

                case 1:
                {
                    AddressBook.PrintAddressBookDetails(bookName);
                    break;
                }

                case 2:
                {
                    InputForAddressDetails.TakeInputForAddress(bookName);
                    break;
                }

                case 3:
                {
                    AddressDetailsManipulationMenu.EditDetails(bookName);
                    break;
                }

                case 4:
                {
                    AddressDetailsManipulation.SortByLastName(bookName);
                    break;
                }

                case 5:
                {
                    AddressDetailsManipulation.SortByZip(bookName);
                    break;
                }

                default:
                {
                    Console.WriteLine("Invalid Input");
                    break;
                }
                }
            }
        }