2024-10-16 08:22:40 +00:00
|
|
|
|
using Demo.Domain.UseCase;
|
2024-10-18 14:03:25 +00:00
|
|
|
|
using Demo.domain.Models;
|
2024-10-16 08:22:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Demo.UI
|
|
|
|
|
{
|
|
|
|
|
public class UserConsoleUI
|
|
|
|
|
{
|
|
|
|
|
UserUseCase _userUseCase;
|
|
|
|
|
public UserConsoleUI(UserUseCase userUseCase) {
|
|
|
|
|
_userUseCase = userUseCase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveUserByGuid(Guid guidUser) {
|
|
|
|
|
|
2024-10-18 14:03:25 +00:00
|
|
|
|
string del = _userUseCase.RemoveUserByGuid(guidUser) ? "Пользователь удален" : "Пользователь не удален";
|
|
|
|
|
Console.WriteLine(del);
|
2024-10-16 08:22:40 +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-18 14:03:25 +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-16 08:22:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|