2024-10-18 09:51:43 +00:00
|
|
|
|
using Demo.domain.Models;
|
|
|
|
|
using Demo.Domain.UseCase;
|
2024-10-14 12:10:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Demo.UI
|
|
|
|
|
{
|
|
|
|
|
public class UserConsoleUI
|
|
|
|
|
{
|
|
|
|
|
UserUseCase _userUseCase;
|
2024-10-18 09:51:43 +00:00
|
|
|
|
|
|
|
|
|
public UserConsoleUI(UserUseCase userUseCase)
|
|
|
|
|
{
|
2024-10-14 12:10:53 +00:00
|
|
|
|
_userUseCase = userUseCase;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-18 09:51:43 +00:00
|
|
|
|
public void RemoveUserByGuid(Guid guidUser)
|
|
|
|
|
{
|
2024-10-16 07:01:04 +00:00
|
|
|
|
string output = _userUseCase.RemoveUserByGuid(guidUser) ? "Пользователь удален" : "Пользователь не удален";
|
|
|
|
|
Console.WriteLine(output);
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-14 12:10:53 +00:00
|
|
|
|
public void DisplayAllUsers()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder userOutput = new StringBuilder();
|
2024-10-16 07:01:04 +00:00
|
|
|
|
foreach (var user in _userUseCase.GetAllUsers())
|
2024-10-14 12:10:53 +00:00
|
|
|
|
{
|
|
|
|
|
userOutput.AppendLine($"{user.Guid}\t{user.FIO}\t{user.Group.Name}");
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine(userOutput);
|
|
|
|
|
}
|
2024-10-18 09:51:43 +00:00
|
|
|
|
|
|
|
|
|
public void FindUserByGuid(Guid userGuid)
|
|
|
|
|
{
|
|
|
|
|
var user = _userUseCase.FindUserByGuid(userGuid);
|
|
|
|
|
if (user == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Пользователь не найден.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Найден пользователь: {user.Guid}, {user.FIO}, Группа: {user.Group?.Name}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-30 09:11:19 +00:00
|
|
|
|
public void UpdateUser(Guid userGuid, User updatedUser)
|
2024-10-18 09:51:43 +00:00
|
|
|
|
{
|
2024-10-30 09:11:19 +00:00
|
|
|
|
var result = _userUseCase.UpdateUser(userGuid, updatedUser);
|
2024-10-18 09:51:43 +00:00
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Пользователь обновлён.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Пользователь не найден.");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-14 12:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|