2024-10-19 21:12:06 +00:00
|
|
|
|
using Demo.Domain.UseCase;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Demo.UI
|
|
|
|
|
{
|
|
|
|
|
public class MainMenuUI
|
|
|
|
|
{
|
2024-10-19 21:39:57 +00:00
|
|
|
|
private UserConsoleUI _userConsoleUI;
|
2024-10-19 21:12:06 +00:00
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
public MainMenuUI(UserUseCase userUseCase)
|
|
|
|
|
{
|
|
|
|
|
_userConsoleUI = new UserConsoleUI(userUseCase);
|
2024-10-19 21:12:06 +00:00
|
|
|
|
DisplayMenu();
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
private void DisplayMenu()
|
|
|
|
|
{
|
2024-10-19 21:12:06 +00:00
|
|
|
|
while (true)
|
|
|
|
|
{
|
2024-10-19 21:39:57 +00:00
|
|
|
|
Console.Clear();
|
|
|
|
|
Console.WriteLine("Главное меню:");
|
|
|
|
|
Console.WriteLine("1. Показать всех пользователей");
|
|
|
|
|
Console.WriteLine("2. Удалить пользователя по GUID");
|
|
|
|
|
Console.WriteLine("0. Выход");
|
|
|
|
|
|
|
|
|
|
string choice = Console.ReadLine();
|
2024-10-19 21:12:06 +00:00
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
switch (choice)
|
|
|
|
|
{
|
|
|
|
|
case "1":
|
|
|
|
|
_userConsoleUI.DisplayAllUsers();
|
|
|
|
|
break;
|
|
|
|
|
case "2":
|
|
|
|
|
RemoveUser();
|
|
|
|
|
break;
|
|
|
|
|
case "0":
|
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
Console.WriteLine("Неверный выбор, попробуйте снова.");
|
2024-10-19 21:12:06 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
Console.WriteLine("Нажмите любую клавишу для продолжения...");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveUser()
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Введите GUID пользователя для удаления: ");
|
|
|
|
|
string input = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
if (Guid.TryParse(input, out Guid userGuid))
|
|
|
|
|
{
|
|
|
|
|
_userConsoleUI.RemoveUserByGuid(userGuid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Неверный формат GUID. Пожалуйста, попробуйте еще раз.");
|
2024-10-19 21:12:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-19 21:39:57 +00:00
|
|
|
|
}
|