using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Posechaemost.Domain.UseCase; namespace Posechaemost.UI { public class PresenceConsoleUI { PresenceUseCase _presenceUseCase; public PresenceConsoleUI(PresenceUseCase presenceUseCase) { _presenceUseCase = presenceUseCase; } public void GetPresenceByGroup(int groupId) { StringBuilder presenceOutput = new StringBuilder(); var presence = _presenceUseCase.GetPresenceByGroup(groupId); foreach (var p in presence) { presenceOutput.AppendLine($"{p.User.UserId}\t{p.User.FIO}\t{p.ClassNumber}\t{p.Date}\t{p.IsAttendence}"); } Console.WriteLine(presenceOutput); } public void GetPresenceByGroupAndDate(int groupId, DateOnly date) { StringBuilder presenceOutput = new StringBuilder(); var presence = _presenceUseCase.GetPresenceByGroupAndDate(groupId, date); foreach (var p in presence) { presenceOutput.AppendLine($"{p.User.UserId}\t{p.User.FIO}\t{p.ClassNumber}\t{p.Date}\t{p.IsAttendence}"); } Console.WriteLine(presenceOutput); } public void UncheckAttendence(int firstClass, int lastClass, DateOnly date, int userId) { string output = _presenceUseCase.UncheckAttendence(firstClass, lastClass, date, userId) ? "Посещаемость обновлена" : "Посещаемость не обновлена"; Console.WriteLine(output); } public void AddPresence(int firstClass, int lastClass, int groupId, DateOnly date) { StringBuilder presenceOutput = new StringBuilder(); _presenceUseCase.AddPresence(firstClass, lastClass, groupId, date); presenceOutput.AppendLine("Посещаемость добавлена"); Console.WriteLine(presenceOutput); } } }