slarny4/Demo1/UI/PresenceConsole.cs

48 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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