47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Demo.Domain.UseCase;
|
|
using Demo.domain.Models;
|
|
using System.Text;
|
|
|
|
|
|
namespace Demo.UI
|
|
{
|
|
public class GroupConsoleUI
|
|
{
|
|
IGroupUseCase _groupUseCase;
|
|
|
|
public GroupConsoleUI(IGroupUseCase groupUseCase) {
|
|
_groupUseCase = groupUseCase;
|
|
}
|
|
|
|
public void UpdateGroupName(Group group)
|
|
{
|
|
try
|
|
{
|
|
Group output = _groupUseCase.UpdateGroupName(group);
|
|
StringBuilder groupOutput = new StringBuilder();
|
|
groupOutput.AppendLine($"Обновленная группа: {output.Id}\t{output.Name}");
|
|
Console.WriteLine(groupOutput);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Ошибка при обновлении группы: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public void CreateNewGroup(Group group){
|
|
string output = _groupUseCase.CreateGroup(group) ? "Пользователь создан" : "Пользователь не создан";
|
|
}
|
|
|
|
public void DisplayAllGroups()
|
|
{
|
|
StringBuilder groupOutput = new StringBuilder();
|
|
foreach (var group in _groupUseCase.GetAllGroups())
|
|
{
|
|
groupOutput.AppendLine($"{group.Id}\t {group.Name}\t");
|
|
}
|
|
Console.WriteLine(groupOutput);
|
|
}
|
|
}
|
|
|
|
}
|