2024-12-23 09:12:26 +00:00
|
|
|
|
using presence.domain.Models;
|
|
|
|
|
using presence.domain.UseCase;
|
2024-11-20 17:50:01 +00:00
|
|
|
|
using System;
|
2024-12-23 09:12:26 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2024-11-20 17:50:01 +00:00
|
|
|
|
using System.Text;
|
2024-12-23 09:12:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2024-11-20 17:50:01 +00:00
|
|
|
|
|
2024-12-23 09:12:26 +00:00
|
|
|
|
namespace presence.ui
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
2024-12-05 09:30:01 +00:00
|
|
|
|
public class GroupConsoleUI
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
2024-12-23 09:12:26 +00:00
|
|
|
|
GroupUseCase _groupUseCase;
|
2024-12-05 09:30:01 +00:00
|
|
|
|
public GroupConsoleUI(GroupUseCase groupUseCase)
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
2024-12-05 09:30:01 +00:00
|
|
|
|
_groupUseCase = groupUseCase;
|
2024-11-20 17:50:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-23 09:12:26 +00:00
|
|
|
|
public void AddGroup(String name, String id) //Метод для добавления новой группы
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
2024-12-23 09:12:26 +00:00
|
|
|
|
int Id;
|
|
|
|
|
bool isParsed = int.TryParse(id, out Id);
|
|
|
|
|
if (!isParsed)
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
2024-12-23 09:12:26 +00:00
|
|
|
|
Console.WriteLine("Введено не число");
|
2024-11-20 17:50:01 +00:00
|
|
|
|
}
|
2024-12-23 09:12:26 +00:00
|
|
|
|
string output = _groupUseCase.AddGroup(name, Id) ? "Группа добавлена" : "Группа не добавлена";
|
|
|
|
|
Console.WriteLine(output);
|
2024-11-20 17:50:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-23 09:12:26 +00:00
|
|
|
|
public void UpdateGroupName(String name, String name1) //Метод для обновления имени группы
|
|
|
|
|
{
|
|
|
|
|
string output = _groupUseCase.UpdateGroupName(name, name1) ? "Группа обновлена" : "Группа не обновлена";
|
|
|
|
|
Console.WriteLine(output);
|
|
|
|
|
}
|
2024-12-05 09:30:01 +00:00
|
|
|
|
|
2024-12-23 09:12:26 +00:00
|
|
|
|
public void DisplayAllGroups() //Метод для вывода всех существующих групп
|
2024-11-20 17:50:01 +00:00
|
|
|
|
{
|
|
|
|
|
StringBuilder groupOutput = new StringBuilder();
|
|
|
|
|
foreach (var group in _groupUseCase.GetAllGroups())
|
|
|
|
|
{
|
|
|
|
|
groupOutput.AppendLine($"{group.Id}\t{group.Name}");
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine(groupOutput);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|