61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Demo.Domain.UseCase;
|
|
using System;
|
|
|
|
namespace Demo.UI
|
|
{
|
|
public class UserConsole
|
|
{
|
|
private readonly UserUseCase _userUseCase;
|
|
|
|
public UserConsole(UserUseCase userUseCase)
|
|
{
|
|
_userUseCase = userUseCase;
|
|
}
|
|
|
|
public void ShowAllUsers()
|
|
{
|
|
var users = _userUseCase.GetAllUsers();
|
|
if (users.Count == 0)
|
|
{
|
|
Console.WriteLine("No users found.");
|
|
return;
|
|
}
|
|
|
|
foreach (var user in users)
|
|
{
|
|
Console.WriteLine($"User GUID: {user.Guid}, FIO: {user.FIO}, Group ID: {user.GroupID}");
|
|
}
|
|
}
|
|
|
|
public void UpdateUser(Guid userGuid)
|
|
{
|
|
Console.WriteLine("Enter new FIO:");
|
|
string newFIO = Console.ReadLine();
|
|
Console.WriteLine("Enter new Group ID:");
|
|
int newGroupID = int.Parse(Console.ReadLine());
|
|
|
|
_userUseCase.UpdateUser(userGuid, newFIO, newGroupID);
|
|
Console.WriteLine("User updated successfully.");
|
|
}
|
|
|
|
public void DeleteUser(Guid userGuid)
|
|
{
|
|
_userUseCase.DeleteUserByGuid(userGuid);
|
|
Console.WriteLine("User deleted successfully.");
|
|
}
|
|
|
|
public void FindUser(Guid userGuid)
|
|
{
|
|
var user = _userUseCase.FindUserByGuid(userGuid);
|
|
if (user != null)
|
|
{
|
|
Console.WriteLine($"User found: {user.FIO}, Group ID: {user.GroupID}");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("User not found.");
|
|
}
|
|
}
|
|
}
|
|
}
|