Demo/UI/MainMenu.cs

58 lines
2.8 KiB
C#
Raw Normal View History

using Demo.Domain.UseCase;
2024-10-17 12:35:14 +00:00
using Demo.domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.UI
{
public class MainMenuUI
{
2024-10-17 12:35:14 +00:00
UserConsoleUI _userConsoleUI;
2024-10-17 12:35:14 +00:00
GroupConsoleUI _groupConsoleUI;
2024-10-23 19:46:46 +00:00
PresenceConsoleUI _presenceConsoleUI;
2024-10-23 19:46:46 +00:00
public MainMenuUI(IUserUseCase userUseCase, IGroupUseCase groupUseCase, IPresenceUseCase presenceUseCase) {
_userConsoleUI = new UserConsoleUI(userUseCase);
2024-10-17 12:35:14 +00:00
_groupConsoleUI = new GroupConsoleUI(groupUseCase);
2024-10-23 19:46:46 +00:00
_presenceConsoleUI = new PresenceConsoleUI(presenceUseCase);
DisplayMenu();
}
private void DisplayMenu() {
while (true)
{
switch (Console.ReadLine())
{
2024-10-24 20:41:31 +00:00
case "1": _userConsoleUI.DisplayAllUsers(); break;
2024-10-24 20:41:31 +00:00
case "2": _userConsoleUI.GetUserByGuid(Guid.Parse(Console.ReadLine())); break;
2024-10-17 12:35:14 +00:00
case "3": _userConsoleUI.UpdateUser(User.Parse(Console.ReadLine())); break;
2024-10-24 20:41:31 +00:00
case "4": _userConsoleUI.RemoveUserByGuid(Guid.Parse(Console.ReadLine())); break;
2024-10-17 12:35:14 +00:00
case "5": _groupConsoleUI.DisplayAllGroups(); break;
2024-10-24 20:41:31 +00:00
case "6": _groupConsoleUI.CreateNewGroup(Console.ReadLine()); break;
2024-10-17 12:35:14 +00:00
case "7": _groupConsoleUI.UpdateGroupName(Group.Parse(Console.ReadLine())); break;
2024-10-24 20:41:31 +00:00
case "8": _groupConsoleUI.DisplayGroupByID(Convert.ToInt32(Console.ReadLine())); break;
case "9": _groupConsoleUI.RemoveGroupById(Convert.ToInt32(Console.ReadLine())); break;
case "10": _presenceConsoleUI.DisplayPresenceByGroup(Convert.ToInt32(Console.ReadLine())); break;
case "11": _presenceConsoleUI.DisplayPresenceByGroupAndDate(Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine()))); break;
case "12": _presenceConsoleUI.GeneratePresence(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine()))); break;
case "13": _presenceConsoleUI.GeneratePresenceWeek(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine()))); break;
case "14": _presenceConsoleUI.IsAttedance(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), DateOnly.FromDateTime(Convert.ToDateTime(Console.ReadLine())), Guid.Parse(Console.ReadLine())); break;
default: DisplayMenu();
break;
}
}
}
}
}