slarny4/Demo1/UI/PresenceConsole.cs

48 lines
1.8 KiB
C#
Raw Normal View History

2024-11-25 04:33:26 +00:00
using Demo.Domain.UseCase;
using System;
using System.Linq;
2024-10-24 08:50:32 +00:00
2024-11-25 04:33:26 +00:00
namespace Demo.UI
2024-10-24 08:50:32 +00:00
{
public class PresenceConsole
{
2024-11-25 04:33:26 +00:00
private readonly UseCasePresence _presenceUseCase;
private readonly UserUseCase _userUseCase;
2024-10-24 08:50:32 +00:00
2024-11-25 04:33:26 +00:00
public PresenceConsole(UseCasePresence presenceUseCase, UserUseCase userUseCase)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
_presenceUseCase = presenceUseCase;
_userUseCase = userUseCase;
2024-10-24 08:50:32 +00:00
}
2024-11-25 04:33:26 +00:00
public void DisplayPresenceByGroup(int groupId)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
var presence = _presenceUseCase.GetPresenceByGroup(groupId);
var users = _userUseCase.GetAllUsers().ToDictionary(u => u.Id);
2024-10-24 08:50:32 +00:00
2024-11-25 04:33:26 +00:00
foreach (var p in presence)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
var user = users[p.UserId];
Console.WriteLine($"Дата: {p.Date}, Занятие: {p.LessonNumber}, ФИО: {user.FIO}, Посещаемость: {(p.IsAttendance ? "Присутствовал" : "Отсутствовал")}");
2024-10-24 08:50:32 +00:00
}
}
2024-11-25 04:33:26 +00:00
public void DisplayPresenceByGroupAndDate(int groupId, DateTime date)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
var presence = _presenceUseCase.GetPresenceByGroupAndDate(groupId, date);
var users = _userUseCase.GetAllUsers().ToDictionary(u => u.Id);
2024-10-24 08:50:32 +00:00
2024-11-25 04:33:26 +00:00
foreach (var p in presence)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
var user = users[p.UserId];
Console.WriteLine($"Дата: {p.Date}, Занятие: {p.LessonNumber}, ФИО: {user.FIO}, Посещаемость: {(p.IsAttendance ? "Присутствовал" : "Отсутствовал")}");
2024-10-24 08:50:32 +00:00
}
}
2024-11-25 04:33:26 +00:00
public void MarkUserAsAbsent(Guid userId, int lessonNumber, DateTime date)
2024-10-24 08:50:32 +00:00
{
2024-11-25 04:33:26 +00:00
_presenceUseCase.MarkUserAsAbsent(userId, lessonNumber, date);
Console.WriteLine("Пользователь отмечен как отсутствующий.");
2024-10-24 08:50:32 +00:00
}
}
}