Demo/UI/UserConsole.cs

51 lines
1.7 KiB
C#
Raw Permalink Normal View History

using Posechaemost.Data.LocalData.Entity;
using Posechaemost.Domain.UseCase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Posechaemost.UI
{
public class UserConsoleUI
{
UserUseCase _userUseCase;
public UserConsoleUI(UserUseCase userUseCase) {
_userUseCase = userUseCase;
}
public void RemoveUserByGuid(Guid guidUser) {
string output = _userUseCase.RemoveUserByGuid(guidUser) ? "Пользователь удален" : "Пользователь не удален";
Console.WriteLine(output);
}
2024-10-18 06:47:43 +00:00
public void DisplayAllUsers()
{
StringBuilder userOutput = new StringBuilder();
foreach (var user in _userUseCase.GetAllUsers())
{
userOutput.AppendLine($"{user.Guid}\t{user.FIO}\t{user.GroupId.Name}");
}
Console.WriteLine(userOutput);
}
2024-10-18 06:47:43 +00:00
public void GetUserByGuid(Guid userGuid) {
StringBuilder userOutput = new StringBuilder();
var user = _userUseCase.GetUserByGuid(userGuid);
userOutput.AppendLine($"{user.Guid}\t{user.FIO}\t{user.GroupID}");
Console.WriteLine(userOutput);
}
public void UpdateUserByGuid(Guid userGuid, String name, String groupId) {
StringBuilder userOutput = new StringBuilder();
var user = _userUseCase.UpdateUserByGuid(userGuid, name, groupId);
userOutput.AppendLine($"{user.Guid}\t{user.FIO}\t{user.GroupId.Name}");
Console.WriteLine(userOutput);
2024-10-18 06:47:43 +00:00
}
}
}
2024-10-18 06:47:43 +00:00