2024-11-08 16:52:52 +00:00
|
|
|
|
using Demo.Domain.UseCase;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Demo.UI
|
|
|
|
|
{
|
|
|
|
|
public class GroupConsoleUI
|
|
|
|
|
{
|
|
|
|
|
private readonly GroupUseCase _groupUseCase;
|
|
|
|
|
|
|
|
|
|
public GroupConsoleUI(GroupUseCase groupUseCase)
|
|
|
|
|
{
|
|
|
|
|
_groupUseCase = groupUseCase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FindGroupById(int IdGroup)
|
|
|
|
|
{
|
|
|
|
|
var groups = _groupUseCase.FindGroupById(IdGroup);
|
2024-11-14 07:53:42 +00:00
|
|
|
|
if (groups != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(groups);
|
|
|
|
|
}
|
2024-11-08 16:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод для отображения всех групп
|
|
|
|
|
public void DisplayAllGroups()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\n=== Список всех групп ===");
|
|
|
|
|
StringBuilder groupOutput = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
foreach (var group in _groupUseCase.GetAllGroups())
|
|
|
|
|
{
|
|
|
|
|
groupOutput.AppendLine($"{group.Id}\t{group.Name}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(groupOutput);
|
|
|
|
|
Console.WriteLine("===========================\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод для добавления новой группы
|
|
|
|
|
public void AddGroup(string groupName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_groupUseCase.AddGroup(groupName);
|
|
|
|
|
Console.WriteLine($"\nГруппа {groupName} добавлена.\n");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Ошибка: {ex.Message}\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод для обновления названия группы
|
|
|
|
|
public void UpdateGroupName(int groupId, string newGroupName)
|
|
|
|
|
{
|
2024-11-14 07:53:42 +00:00
|
|
|
|
if (_groupUseCase.UpdateGroup(groupId, newGroupName))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"\nНазвание группы с ID {groupId} изменено на {newGroupName}.\n");
|
|
|
|
|
}
|
2024-11-08 16:52:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|