2024-10-19 21:39:57 +00:00
|
|
|
|
using Demo.domain.Models;
|
|
|
|
|
using Demo.Domain.UseCase;
|
2024-10-19 21:12:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Demo.UI
|
|
|
|
|
{
|
2024-10-19 21:39:57 +00:00
|
|
|
|
|
2024-10-19 21:12:06 +00:00
|
|
|
|
public class UserConsoleUI
|
|
|
|
|
{
|
|
|
|
|
UserUseCase _userUseCase;
|
2024-10-19 21:39:57 +00:00
|
|
|
|
public UserConsoleUI(UserUseCase userUseCase)
|
|
|
|
|
{
|
2024-10-19 21:12:06 +00:00
|
|
|
|
_userUseCase = userUseCase;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
public void RemoveUserByGuid(Guid guidUser)
|
|
|
|
|
{
|
2024-10-19 21:12:06 +00:00
|
|
|
|
|
2024-10-19 21:39:57 +00:00
|
|
|
|
string del = _userUseCase.RemoveUserByGuid(guidUser) ? "Пользователь удален" : "Пользователь не удален";
|
|
|
|
|
Console.WriteLine(del);
|
2024-10-19 21:12:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DisplayAllUsers()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder userOutput = new StringBuilder();
|
|
|
|
|
foreach (var user in _userUseCase.GetAllUsers())
|
|
|
|
|
{
|
|
|
|
|
userOutput.AppendLine($"{user.Guid}\t{user.FIO}\t{user.Group.Name}");
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine(userOutput);
|
|
|
|
|
}
|
2024-10-19 21:39:57 +00:00
|
|
|
|
|
|
|
|
|
public void UpdateUserGuid(Guid guidUser)
|
|
|
|
|
{
|
|
|
|
|
var user = _userUseCase.FindUserByGuid(guidUser);
|
|
|
|
|
Console.WriteLine($"Текущие данные: {user.FIO}, {user.Group.Name}");
|
|
|
|
|
Console.Write("Введите новое ФИО: ");
|
|
|
|
|
string newFIO = Console.ReadLine();
|
|
|
|
|
user.FIO = newFIO;
|
|
|
|
|
_userUseCase.UpdateUser(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GetUserByGuid(Guid guidUser)
|
|
|
|
|
{
|
|
|
|
|
var user = _userUseCase.FindUserByGuid(guidUser);
|
|
|
|
|
Console.WriteLine($"Пользователь найден: {user.Guid}, {user.FIO}, {user.Group.Name}");
|
|
|
|
|
}
|
2024-10-19 21:12:06 +00:00
|
|
|
|
}
|
2024-10-19 21:39:57 +00:00
|
|
|
|
}
|