Demo/UI/MainMenu.cs
2024-10-22 21:51:54 +03:00

47 lines
2.1 KiB
C#

using Demo.Domain.Models;
using Demo.Domain.UseCase;
namespace Demo.UI
{
public class MainMenuUI
{
UserConsoleUI _userConsoleUI;
GroupConsoleUI _groupConsoleUI;
PresenceConsoleUI _presenceConsoleUI;
public MainMenuUI(IUserUseCase userUseCase, IGroupUseCase groupUseCase, IPresenceUseCase presenceUseCase) {
_userConsoleUI = new UserConsoleUI(userUseCase);
_groupConsoleUI = new GroupConsoleUI(groupUseCase);
_presenceConsoleUI = new PresenceConsoleUI(presenceUseCase);
DisplayMenu();
}
private void DisplayMenu() {
while (true)
{
switch (Console.ReadLine())
{
case "1": _userConsoleUI.DisplayAllUsers(); break;
case "2": _userConsoleUI.RemoveUserByGuid(Guid.Parse(Console.ReadLine())); break;
case "3": _userConsoleUI.UpdateUserByGuid(User.Parse(Console.ReadLine())); break;
case "4": _userConsoleUI.DisplayUserByGuid(Guid.Parse(Console.ReadLine())); break;
case "5": _groupConsoleUI.DisplayAllGroups(); break;
case "6": _groupConsoleUI.CreateNewGroup(Group.Parse(Console.ReadLine())); break;
case "7": _groupConsoleUI.UpdateGroupName(Group.Parse(Console.ReadLine())); break; //todo
case "10": Console.WriteLine("писяпопакака"); break;
case "777": _presenceConsoleUI.DisplayPresenceByGroup(Convert.ToInt32(Console.ReadLine())); break;
case "888": _presenceConsoleUI.DisplayPresenceByGroupByTime(Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine()))); break;
case "999": _presenceConsoleUI.GeneratePresence(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine()))); break;
default: DisplayMenu();
break;
}
}
}
}
}