public static Profile CreateProfile() { Console.Clear(); Console.WriteLine("Создание новой записи!!"); string name = ValidatorProfileClass.GetStrDataProfile("Введите имя контакта:"); string secondName = ValidatorProfileClass.GetStrDataProfile("Введите фамилию:"); string phone = ValidatorProfileClass.GetPhoneProfile("Введите номер телефона:"); string country = ValidatorProfileClass.GetStrDataProfile("Введите название страны:"); Profile profile = new Profile(name, secondName, country, phone); while (true) { Console.WriteLine("Вы хотите заполнить остальные поля? (y/n)"); string answerUser = Console.ReadLine(); if (answerUser.ToLower().Equals("y")) { profile.Patronymic = ValidatorProfileClass.GetStrDataProfile("Введите отчество контакта:"); profile.DateOfBirth = ValidatorProfileClass.GetDateProfile("Введите дату рождения:"); profile.Organisation = ValidatorProfileClass.GetStrDataProfile("Введите название организации контакта:"); profile.Position = ValidatorProfileClass.GetStrDataProfile("Введите должность контакта:"); profile.Other = ValidatorProfileClass.GetStrDataProfile("Введите дополнительную информацию о пользователе:"); break; } else if (answerUser.ToLower().Equals("n")) { break; } else { Console.WriteLine("Некорректное значение. Повторите ввод!"); } } UpdateLenArrStr(profile); return(profile); }
private static Profile EditProfile(Profile profile) { while (true) { Console.Clear(); Console.WriteLine("Редактирование записи"); Console.WriteLine(profile); Console.WriteLine("Выберите команду, для редактирования поля в профиле:"); Console.WriteLine("1 - Имя"); Console.WriteLine("2 - Фамилия"); Console.WriteLine("3 - Отчество"); Console.WriteLine("4 - Номер телефона"); Console.WriteLine("5 - Страна"); Console.WriteLine("6 - Дата рождения"); Console.WriteLine("7 - Организация"); Console.WriteLine("8 - Позиция"); Console.WriteLine("9 - Другое"); Console.WriteLine("10 - Завершить редактирование"); if (int.TryParse(Console.ReadLine(), out int cmd) && (cmd < 1 || cmd > 10)) { continue; } else if (cmd == 10) { break; } switch (cmd) { case 1: profile.Name = ValidatorProfileClass.GetStrDataProfile("Введите имя контакта:"); break; case 2: profile.SecondName = ValidatorProfileClass.GetStrDataProfile("Введите фамилию контакта:"); break; case 3: profile.Patronymic = ValidatorProfileClass.GetStrDataProfile("Введите отчество контакта:"); break; case 4: profile.Phone = ValidatorProfileClass.GetPhoneProfile("Введите номер телефона пользователя:"); break; case 5: profile.Country = ValidatorProfileClass.GetStrDataProfile("Введите страну контакта:"); break; case 6: profile.DateOfBirth = ValidatorProfileClass.GetDateProfile("Введите дату рождения:"); break; case 7: profile.Organisation = ValidatorProfileClass.GetStrDataProfile("Введите название организации контакта:"); break; case 8: profile.Position = ValidatorProfileClass.GetStrDataProfile("Введите должность контакта:"); break; case 9: profile.Other = ValidatorProfileClass.GetStrDataProfile("Введите дополнительную информацию о пользователе:"); break; } } UpdateLenArrStr(profile); return(profile); }