Studety/Demo/UI/UserConsole.cs

63 lines
2.0 KiB
C#
Raw Normal View History

2024-10-18 06:12:15 +00:00
using Demo.Domain.UseCase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.UI
{
public class UserConsoleUI
{
UserUseCase _userUseCase;
GroupUseCase _groupsUseCase;
public UserConsoleUI(UserUseCase userUseCase) {
_userUseCase = userUseCase;
_groupUseCase = GroupUseCase;
}
public void RemoveUserByGuid(Guid guidUser) {
string output = _userUseCase.RemoveUserByGuid(guidUser) ? "Пользователь удален" : "Пользователь не удален";
Console.WriteLine(output);
}
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);
}
public void UpdateUsers(Guid guidUser, User updatedUser)
{
string output = _userUseCase.UpdateUser(guidUser, updatedUser) ? "Пользователь обновлен" : "Пользователь не обновлен";
Console.WriteLine(output);
}
public void SerchUsers(Guid guidUser)
{
var user = _userUseCase.FindUserByGuid(guidUser);
if (user != null)
{
Console.WriteLine($"{user.Guid}\t{user.FIO}\t{user.Group.Name}");
}
else
{
Console.WriteLine("Ненаход");
}
public void DisplayAllGroup()
{
StringBuilder userOutput = new StringBuilder();
foreach (var user in _groupsUseCase.GetAllGroup())
{
userOutput.AppendLine($"{it.Id}\t{it.Name}");
}
Console.WriteLine(userOutput);
}
}
}
}