Demo/UI/PresenceConsole.cs
2024-10-23 22:46:46 +03:00

46 lines
2.1 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 Demo.domain.Models;
using System.Text;
namespace Demo.UI
{
public class PresenceConsoleUI {
IPresenceUseCase _presenceUseCase;
public PresenceConsoleUI (IPresenceUseCase presenceUseCase){
_presenceUseCase = presenceUseCase;
}
public void DisplayPresenceByGroup(int groupID){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresencesByGroup(groupID)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
public void DisplayPresenceByGroupByTime(int groupID, DateOnly date){
StringBuilder stringBuilder = new StringBuilder();
foreach(Presence presence in _presenceUseCase.GetPresencesByGroupAndDate(groupID, date)){
stringBuilder.AppendLine($"{presence.User.FIO}, {presence.User.Group.Name}, {presence.IsAttedance}, {presence.Date}, {presence.LessonNumber}");
}
Console.WriteLine(stringBuilder);
}
public void GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GeneratePresence(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
public void GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date){
string output = _presenceUseCase.GenerateWeekPresence(firstLesson, lastLesson, groupID, date) ? "Сгенерированно" : "Не сгенерированно";
Console.WriteLine(output);
}
public void IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid){
string output = _presenceUseCase.UpdateAttedance(firstLesson, lastLesson, date, UserGuid) ? "Обновлено" : "Не обновлено";
Console.WriteLine(output);
}
}
}