61 lines
1.9 KiB
C#
61 lines
1.9 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(string Name){
|
|
string output = _groupUseCase.CreateGroup(Name) ? "Группа создана" : "Группа не создана";
|
|
Console.WriteLine(output);
|
|
}
|
|
|
|
public void DisplayAllGroups()
|
|
{
|
|
StringBuilder userOutput = new StringBuilder();
|
|
foreach (var group in _groupUseCase.GetAllGroups())
|
|
{
|
|
userOutput.AppendLine($"{group.Id}\t{group.Name}");
|
|
}
|
|
Console.WriteLine(userOutput);
|
|
}
|
|
|
|
public void RemoveGroupById(int ID){
|
|
string output = _groupUseCase.RemoveGroupById(ID) ? "Группа удалена" : "Группа не удалена";
|
|
Console.WriteLine(output);
|
|
}
|
|
|
|
public void DisplayGroupByID(int ID){
|
|
StringBuilder userOutput = new StringBuilder();
|
|
var group = _groupUseCase.GetGroupById(ID);
|
|
{
|
|
userOutput.AppendLine($"{group.Id}\t{group.Name}");
|
|
}
|
|
Console.WriteLine(userOutput);
|
|
}
|
|
}
|
|
}
|