// Method to modify a specific customer which exists in the crm file public void ModifyCustomerSubmenu(bool clear = true) { if (clear) { Console.Clear(); } Console.WriteLine("### Modify Customer Submenu ###\n"); ModifyCRMValidationInput(); // Return the customer which matches the provided ID to modify and assign to modifiedcustomer object Customer customer = Crm.GetCustomer(IDtoMofify); // if the returned customer in the modified customer object is not null, proceed to modify if (customer != null) { // Store old customers ID, title, first and last names into variables int OldID = customer.ID; string OldTitle = customer.title, OldFirstName = customer.firstName, OldLastName = customer.lastName; // Set the customer ID to the highest id value + 1, in case the customer wants to retain his/her ID and only wants // to modify the fields. We set the ID to this so that the validation doesnt prompt an error that the ID wanting // to be retained already exists. If the ID is retained, there is still unique ID's in the list int HighestID = Crm.CustomerList.Max(Customer => Customer.ID) + 1; customer.ID = HighestID; // Save the changed ID value in case customer decideds to retain the same ID in the modification menu. Crm.SaveToFile(); ModifyIDValidationInput(); customer.ID = IDtoMofify; Console.Write("Title*: "); title = StringToTitleCase(Console.ReadLine()); customer.title = title; Console.Write("FirstName*: "); firstName = StringToTitleCase(Console.ReadLine()); customer.firstName = firstName; Console.Write("LastName*: "); lastName = StringToTitleCase(Console.ReadLine()); customer.lastName = lastName; GenderValidationInput(); customer.gender = Gender; DOBValidationInput(); customer.DOB = DOB; Console.Write("\nSuccessfully modified customer '{0} - {1} {2} {3}' to '{4} {5} {6} {7}' within the customers list", OldID, OldTitle, OldFirstName, OldLastName, IDtoMofify, title, firstName, lastName); Crm.SaveToFile(); LastMRRCscreen(() => SubMenu("Customer"), () => ModifyCustomerSubmenu()); } // If the returned customer in the object is null, then the customer does not exist else { Console.Clear(); Console.WriteLine("Customer with an ID of '{0}' does not exist in the Customers List\n", IDtoMofify); ModifyCustomerSubmenu(false); LastMRRCscreen(() => SubMenu("Customer"), () => ModifyCustomerSubmenu()); } }