internal static void SearchPage(int MenuIndex) { Console.Clear(); Console.WriteLine("Choose the way of searching:\n" + "\n1.By phone number" + "\n2.By email" + "\n3.By country\n"); int.TryParse(Console.ReadLine(), out MenuIndex); switch (MenuIndex) { case 1: Console.Clear(); Console.WriteLine("Enter user's phone number:\n"); var number = Console.ReadLine(); UserDTO user = null; List <AddressDTO> address = null; try { user = users.GetByNumber(number); address = addresses.GetByUserId(user.UserId); } catch (NullReferenceException) { Console.WriteLine("\nAn error occured. User with this number does not exist."); DefaultNavigation(MenuIndex); return; } catch (Exception ex) { Console.WriteLine($"\nAn error occured.\n{ex.Message}"); DefaultNavigation(MenuIndex); return; } OutputHelper.OutputUserTableData(); OutputHelper.OutputUser(user, address.FirstOrDefault()); OutputHelper.OutputUnderline(); ChangeUserStatus(out MenuIndex); switch (MenuIndex) { case 2: if (OutputHelper.IsActivated) { OutputHelper.OutputActivationInfo(user, users, activatingData); break; } OutputHelper.ActivationConfirmation(user, users, activatingData); break; case 3: if (OutputHelper.IsBlocked) { OutputHelper.OutputBlockingInfo(user, users, blockingData); break; } OutputHelper.BlockingConfirmation(user, users, blockingData); break; case 4: OutputHelper.OutputUserAddresses(user, addresses); break; } DefaultNavigation(MenuIndex); break; case 2: Console.Clear(); Console.WriteLine("Enter user's email:\n"); var email = Console.ReadLine(); try { user = users.GetByEmail(email); address = addresses.GetByUserId(user.UserId); } catch (NullReferenceException) { Console.WriteLine("\nAn error occured. User with this email does not exist."); DefaultNavigation(MenuIndex); return; } catch (Exception ex) { Console.WriteLine($"An error occured.\n{ex.Message}"); DefaultNavigation(MenuIndex); return; } OutputHelper.OutputUserTableData(); OutputHelper.OutputUser(user, address.FirstOrDefault()); OutputHelper.OutputUnderline(); ChangeUserStatus(out MenuIndex); switch (MenuIndex) { case 2: if (OutputHelper.IsActivated) { OutputHelper.OutputActivationInfo(user, users, activatingData); break; } OutputHelper.ActivationConfirmation(user, users, activatingData); break; case 3: if (OutputHelper.IsBlocked) { OutputHelper.OutputBlockingInfo(user, users, blockingData); break; } OutputHelper.BlockingConfirmation(user, users, blockingData); break; case 4: OutputHelper.OutputUserAddresses(user, addresses); break; } DefaultNavigation(MenuIndex); break; case 3: Console.Clear(); Console.WriteLine("Enter country:\n"); var country = Console.ReadLine(); List <AddressDTO> adrs = null; try { adrs = addresses.GetByCountry(country); } catch (NullReferenceException) { Console.WriteLine("\nNo users were found with this address."); DefaultNavigation(MenuIndex); return; } catch (Exception ex) { Console.WriteLine($"An error occurred.\n{ex.Message}"); DefaultNavigation(MenuIndex); return; } List <UserDTO> usrs = new List <UserDTO>(); OutputHelper.OutputUserTableData(); foreach (var u in adrs) { user = users.GetById(u.UserId); var userAdr = user.tblAddresses.Where(uu => uu.UserId == user.UserId); usrs.Add(users.GetById(u.UserId)); Console.WriteLine($" {user.FirstName} {user.LastName}".PadRight(20) + $"| {user.PhoneNumber}".PadRight(15) + $"| {user.Email}".PadRight(30) + $"| {(user.DateOfBirth != null ? "" + $"{user.DateOfBirth.Value.Day}.{user.DateOfBirth.Value.Month}.{user.DateOfBirth.Value.Year}" : "-")}".PadRight(15) + $"| {(user.IsFemale != null ? (user.IsFemale == null ? "Female" : "Male") : "-")}".PadRight(9) + $"| {$"{u.City}, {u.Country}, {u.HouseNumber} {u.Street}"}".PadRight(40) + $"| {(user.IsAdmin == true ? "Admin" : "User")}".PadRight(11) + $"| {(user.IsActivated == true ? "Activated" : "Not activated")}".PadRight(17) + $"| {(user.IsBlocked == true ? "Blocked" : "Not blocked")}".PadRight(15) + $"| {(user.FirstName == "Anna" && user.LastName == "Bagriy" ? " (you)" : "")}"); } OutputHelper.OutputUnderline(); DefaultNavigation(MenuIndex); break; default: OutputHelper.OutputError(); DefaultNavigation(MenuIndex); break; } }