presence_new/ui/GroupConsole.cs
2024-11-16 15:02:17 +03:00

42 lines
1.3 KiB
C#
Executable File

using presence.domain.Models;
using presence.domain.UseCase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace presence.ui
{
public class GroupConsoleUI
{
GroupUseCase _groupUseCase;
public GroupConsoleUI(GroupUseCase groupUseCase) {
_groupUseCase = groupUseCase;
}
public void DisplayAllGroups()
{
StringBuilder groupOutput = new StringBuilder();
foreach (var group in _groupUseCase.GetAllGroups())
{
groupOutput.AppendLine($"{group.Id}\t{group.Name}");
}
Console.WriteLine(groupOutput);
}
public void UpdateGroupName(String name, String name1) {
StringBuilder groupOutput = new StringBuilder();
var group = _groupUseCase.UpdateGroupName(name, name1) ? "Группа обновлена" : "Группа не обновлена";
Console.WriteLine(groupOutput);
}
public void AddGroup(String name, String id)
{
StringBuilder groupOutput = new StringBuilder();
var group = _groupUseCase.AddGroup(name, id) ? "Группа добавлена" : "Группа не добавлена";
Console.WriteLine(groupOutput);
}
}
}