проект 5
This commit is contained in:
parent
0711343c01
commit
5e5477477b
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Demo.domain.Models
|
namespace Demo.domain.Models
|
||||||
{
|
{
|
||||||
internal class PresenceLocalEntity
|
public class PresenceLocalEntity
|
||||||
{
|
{
|
||||||
public required Guid UserGuid { get; set; }
|
public required Guid UserGuid { get; set; }
|
||||||
public bool IsAttedance { get; set; } = true;
|
public bool IsAttedance { get; set; } = true;
|
||||||
|
@ -11,14 +11,14 @@ namespace Demo.Data.LocalData
|
|||||||
public static class LocalStaticData
|
public static class LocalStaticData
|
||||||
{
|
{
|
||||||
public static List<GroupLocalEntity> groups => new List<GroupLocalEntity>
|
public static List<GroupLocalEntity> groups => new List<GroupLocalEntity>
|
||||||
|
|
||||||
{
|
{
|
||||||
new GroupLocalEntity{ Id = 1, Name = "ИП1-21" },
|
new GroupLocalEntity{ Id = 1, Name = "ИП1-21" },
|
||||||
new GroupLocalEntity{ Id = 2, Name = "ИП1-22" },
|
new GroupLocalEntity{ Id = 2, Name = "ИП1-22" },
|
||||||
new GroupLocalEntity{ Id = 3, Name = "ИП1-23" },
|
new GroupLocalEntity{ Id = 3, Name = "ИП1-23" },
|
||||||
};
|
};
|
||||||
|
|
||||||
public static List<UserLocalEnity> users => new List<UserLocalEnity>
|
public static List<UserLocalEnity> users => new List<UserLocalEnity>
|
||||||
{
|
{
|
||||||
new UserLocalEnity{Guid=Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), FIO = "RandomFio", GroupID = 1 },
|
new UserLocalEnity{Guid=Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), FIO = "RandomFio", GroupID = 1 },
|
||||||
new UserLocalEnity{Guid=Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), FIO = "RandomFio1", GroupID = 2 },
|
new UserLocalEnity{Guid=Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), FIO = "RandomFio1", GroupID = 2 },
|
||||||
@ -27,5 +27,43 @@ namespace Demo.Data.LocalData
|
|||||||
new UserLocalEnity{Guid=Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), FIO = "RandomFio4", GroupID = 2 },
|
new UserLocalEnity{Guid=Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), FIO = "RandomFio4", GroupID = 2 },
|
||||||
new UserLocalEnity{Guid=Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), FIO = "RandomFio5", GroupID = 3 },
|
new UserLocalEnity{Guid=Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), FIO = "RandomFio5", GroupID = 3 },
|
||||||
};
|
};
|
||||||
|
public static List<PresenceLocalEntity> presences = new List<PresenceLocalEntity>
|
||||||
|
{
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("e6b9964d-ea9f-420a-84b9-af9633bbfab9"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("8388d931-5bef-41be-a152-78f1aca980ed"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("ed174548-49ed-4503-a902-c970cbf27173"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("ed174548-49ed-4503-a902-c970cbf27173"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("ed174548-49ed-4503-a902-c970cbf27173"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("ed174548-49ed-4503-a902-c970cbf27173"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("ed174548-49ed-4503-a902-c970cbf27173"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("614c0a23-5bd5-43ae-b48e-d5750afbc282"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("614c0a23-5bd5-43ae-b48e-d5750afbc282"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("614c0a23-5bd5-43ae-b48e-d5750afbc282"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("614c0a23-5bd5-43ae-b48e-d5750afbc282"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("614c0a23-5bd5-43ae-b48e-d5750afbc282"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("efcc1473-c116-4244-b3f7-f2341a5c3003"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 1 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 2 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 3 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 4 },
|
||||||
|
new PresenceLocalEntity { UserGuid = Guid.Parse("60640fb3-ace2-4cad-81d5-a0a58bc2dbbd"), IsAttedance = true, Date = DateOnly.FromDateTime(DateTime.Now), LessonNumber = 5 },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,14 @@ namespace Demo.Data.Repository
|
|||||||
|
|
||||||
public bool AddGroup(GroupLocalEntity newGroup)
|
public bool AddGroup(GroupLocalEntity newGroup)
|
||||||
{
|
{
|
||||||
// Проверяем, существует ли группа с таким же ID
|
|
||||||
if (GetAllGroups.Any(g => g.Id == newGroup.Id))
|
if (GetAllGroups.Any(g => g.Id == newGroup.Id))
|
||||||
{
|
{
|
||||||
return false; // Группа с таким ID уже существует
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetAllGroups.Add(newGroup); // Добавляем новую группу
|
GetAllGroups.Add(newGroup);
|
||||||
return true; // Успешное добавление
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace Demo.Data.Repository
|
|||||||
{
|
{
|
||||||
public interface IGroupRepository
|
public interface IGroupRepository
|
||||||
{
|
{
|
||||||
bool AddGroup(GroupLocalEntity newGroup); // Убедитесь, что здесь есть только один метод
|
bool AddGroup(GroupLocalEntity newGroup);
|
||||||
List<GroupLocalEntity> GetAllGroup();
|
List<GroupLocalEntity> GetAllGroup();
|
||||||
GroupLocalEntity GetGroupById(int groupID);
|
GroupLocalEntity GetGroupById(int groupID);
|
||||||
bool RemoveGroupById(int groupID);
|
bool RemoveGroupById(int groupID);
|
||||||
|
@ -30,7 +30,7 @@ namespace Demo.Domain.UseCase
|
|||||||
|
|
||||||
public bool AddGroup(GroupLocalEntity group)
|
public bool AddGroup(GroupLocalEntity group)
|
||||||
{
|
{
|
||||||
// Если метод возвращает true, то группа добавлена успешно
|
|
||||||
return _repositoryGroupImpl.AddGroup(group);
|
return _repositoryGroupImpl.AddGroup(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
Demo/Domain/UseCase/UseCaseGeneratePresence.cs
Normal file
50
Demo/Domain/UseCase/UseCaseGeneratePresence.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using Demo.Data.LocalData;
|
||||||
|
using Demo.domain.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Demo.Domain.UseCase
|
||||||
|
{
|
||||||
|
public class UseCaseGeneratePresence
|
||||||
|
{
|
||||||
|
public List<Presence> GenerateDailyPresence(int startLesson, int endLesson, int groupId, DateTime currentDate)
|
||||||
|
{
|
||||||
|
var users = LocalStaticData.users.Where(u => u.GroupID == groupId).ToList();
|
||||||
|
var presences = new List<Presence>();
|
||||||
|
|
||||||
|
for (int lesson = startLesson; lesson <= endLesson; lesson++)
|
||||||
|
{
|
||||||
|
foreach (var user in users)
|
||||||
|
{
|
||||||
|
presences.Add(new Presence
|
||||||
|
{
|
||||||
|
User = new User
|
||||||
|
{
|
||||||
|
Guid = user.Guid,
|
||||||
|
FIO = user.FIO,
|
||||||
|
Group = new Group { Id = groupId, Name = LocalStaticData.groups.First(g => g.Id == groupId).Name }
|
||||||
|
},
|
||||||
|
Date = DateOnly.FromDateTime(currentDate),
|
||||||
|
LessonNumber = lesson,
|
||||||
|
IsAttedance = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return presences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Presence> GenerateWeeklyPresence(int startLesson, int endLesson, int groupId, DateTime startDate)
|
||||||
|
{
|
||||||
|
var presences = new List<Presence>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
DateTime currentDate = startDate.AddDays(i);
|
||||||
|
var dailyPresences = GenerateDailyPresence(startLesson, endLesson, groupId, currentDate);
|
||||||
|
presences.AddRange(dailyPresences);
|
||||||
|
}
|
||||||
|
return presences;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
Demo/Domain/UseCase/UseCasePresence.cs
Normal file
62
Demo/Domain/UseCase/UseCasePresence.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Demo.Data.LocalData;
|
||||||
|
using Demo.domain.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Demo.Domain.UseCase
|
||||||
|
{
|
||||||
|
public class UseCasePresence
|
||||||
|
{
|
||||||
|
public List<PresenceLocalEntity> GetPresencesByGroupId(int groupId)
|
||||||
|
{
|
||||||
|
return LocalStaticData.presences
|
||||||
|
.Where(p => LocalStaticData.users.Any(u => u.Guid == p.UserGuid && u.GroupID == groupId))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PresenceLocalEntity> GetPresencesByGroupIdAndDate(int groupId, DateOnly date)
|
||||||
|
{
|
||||||
|
return LocalStaticData.presences
|
||||||
|
.Where(p => LocalStaticData.users.Any(u => u.Guid == p.UserGuid && u.GroupID == groupId)
|
||||||
|
&& p.Date == date)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public void MarkUserAsAbsent(Guid userGuid, int startLesson, int endLesson)
|
||||||
|
{
|
||||||
|
var presences = LocalStaticData.presences
|
||||||
|
.Where(p => p.UserGuid == userGuid && p.LessonNumber >= startLesson && p.LessonNumber <= endLesson)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var presence in presences)
|
||||||
|
{
|
||||||
|
presence.IsAttedance = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void GenerateDailySchedule(int groupId, int startLesson, int endLesson)
|
||||||
|
{
|
||||||
|
var usersInGroup = LocalStaticData.users
|
||||||
|
.Where(u => u.GroupID == groupId)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
Console.WriteLine($"Расписание для группы {groupId}:");
|
||||||
|
|
||||||
|
foreach (var user in usersInGroup)
|
||||||
|
{
|
||||||
|
for (int lesson = startLesson; lesson <= endLesson; lesson++)
|
||||||
|
{
|
||||||
|
var presence = new PresenceLocalEntity
|
||||||
|
{
|
||||||
|
UserGuid = user.Guid,
|
||||||
|
IsAttedance = true,
|
||||||
|
Date = DateOnly.FromDateTime(DateTime.Now),
|
||||||
|
LessonNumber = lesson
|
||||||
|
};
|
||||||
|
|
||||||
|
LocalStaticData.presences.Add(presence);
|
||||||
|
|
||||||
|
Console.WriteLine($"User: {user.Guid}, Attended: {presence.IsAttedance}, Date: {presence.Date}, Lesson: {presence.LessonNumber}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,8 @@ class Program
|
|||||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
||||||
GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl);
|
GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl);
|
||||||
|
UseCasePresence presenceUseCase = new UseCasePresence();
|
||||||
|
|
||||||
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase);
|
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase, presenceUseCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,21 @@ using System;
|
|||||||
namespace Demo.UI
|
namespace Demo.UI
|
||||||
{
|
{
|
||||||
public class MainMenuUI
|
public class MainMenuUI
|
||||||
{
|
{
|
||||||
private UserConsoleUI _userConsoleUI;
|
private UserConsoleUI _userConsoleUI;
|
||||||
private GroupConsoleUI _groupConsoleUI;
|
private GroupConsoleUI _groupConsoleUI;
|
||||||
|
private UseCasePresence _presenceUseCase;
|
||||||
|
private PresenceConsoleUI _presenceConsoleUI;
|
||||||
|
|
||||||
|
public MainMenuUI(UserUseCase userUseCase, GroupUseCase groupUseCase, UseCasePresence presenceUseCase)
|
||||||
|
{
|
||||||
|
_userConsoleUI = new UserConsoleUI(userUseCase);
|
||||||
|
_groupConsoleUI = new GroupConsoleUI(groupUseCase);
|
||||||
|
_presenceUseCase = presenceUseCase;
|
||||||
|
_presenceConsoleUI = new PresenceConsoleUI(presenceUseCase);
|
||||||
|
DisplayMenu();
|
||||||
|
}
|
||||||
|
|
||||||
public MainMenuUI(UserUseCase userUseCase, GroupUseCase groupUseCase)
|
|
||||||
{
|
|
||||||
_userConsoleUI = new UserConsoleUI(userUseCase);
|
|
||||||
_groupConsoleUI = new GroupConsoleUI(groupUseCase);
|
|
||||||
DisplayMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisplayMenu()
|
private void DisplayMenu()
|
||||||
{
|
{
|
||||||
@ -29,6 +34,10 @@ namespace Demo.UI
|
|||||||
Console.WriteLine("6 - Добавить группу");
|
Console.WriteLine("6 - Добавить группу");
|
||||||
Console.WriteLine("7 - Обновить группу по ID");
|
Console.WriteLine("7 - Обновить группу по ID");
|
||||||
Console.WriteLine("8 - Удалить группу по ID");
|
Console.WriteLine("8 - Удалить группу по ID");
|
||||||
|
Console.WriteLine("9 - Вывести посещаемость по группе");
|
||||||
|
Console.WriteLine("10 - Вывести посещаемость по группе и дате");
|
||||||
|
Console.WriteLine("11 - Отметить пользователя как отсутствующего");
|
||||||
|
Console.WriteLine("12 - Генерация расписания по диапозону");
|
||||||
Console.WriteLine("0 - Выход");
|
Console.WriteLine("0 - Выход");
|
||||||
|
|
||||||
var input = Console.ReadLine();
|
var input = Console.ReadLine();
|
||||||
@ -108,6 +117,45 @@ namespace Demo.UI
|
|||||||
Console.WriteLine("Некорректный ID группы.");
|
Console.WriteLine("Некорректный ID группы.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "9":
|
||||||
|
Console.WriteLine("Введите ID группы для отображения посещаемости:");
|
||||||
|
string inputGroupId = Console.ReadLine();
|
||||||
|
if (int.TryParse(inputGroupId, out int parsedGroupId))
|
||||||
|
{
|
||||||
|
_presenceConsoleUI.DisplayPresencesByGroupId(parsedGroupId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный ID группы.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "10":
|
||||||
|
Console.WriteLine("Введите ID группы для отображения посещаемости:");
|
||||||
|
inputGroupId = Console.ReadLine();
|
||||||
|
if (int.TryParse(inputGroupId, out parsedGroupId))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите дату (yyyy-MM-dd):");
|
||||||
|
string inputDate = Console.ReadLine();
|
||||||
|
if (DateOnly.TryParse(inputDate, out DateOnly parsedDate))
|
||||||
|
{
|
||||||
|
_presenceConsoleUI.DisplayPresencesByGroupIdAndDate(parsedGroupId, parsedDate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректная дата.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный ID группы.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "11":
|
||||||
|
_presenceConsoleUI.MarkUserAsAbsent();
|
||||||
|
break;
|
||||||
|
case "12":
|
||||||
|
_presenceConsoleUI.GenerateDailySchedule();
|
||||||
|
break;
|
||||||
case "0":
|
case "0":
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
102
Demo/UI/PresenceConcole.cs
Normal file
102
Demo/UI/PresenceConcole.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Demo.Domain.UseCase;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Demo.UI
|
||||||
|
{
|
||||||
|
public class PresenceConsoleUI
|
||||||
|
{
|
||||||
|
private UseCasePresence _useCasePresence;
|
||||||
|
|
||||||
|
public PresenceConsoleUI(UseCasePresence useCasePresence)
|
||||||
|
{
|
||||||
|
_useCasePresence = useCasePresence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayPresencesByGroupId(int groupId)
|
||||||
|
{
|
||||||
|
var presences = _useCasePresence.GetPresencesByGroupId(groupId);
|
||||||
|
Console.WriteLine($"Посещаемость для группы {groupId}:");
|
||||||
|
foreach (var presence in presences)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"User: {presence.UserGuid}, Attended: {presence.IsAttedance}, Date: {presence.Date}, Lesson: {presence.LessonNumber}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DisplayPresencesByGroupIdAndDate(int groupId, DateOnly date)
|
||||||
|
{
|
||||||
|
var presences = _useCasePresence.GetPresencesByGroupId(groupId)
|
||||||
|
.Where(p => p.Date == date)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (presences.Count == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Посещаемость отсутствует для группы {groupId} на {date.ToShortDateString()}.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Посещаемость для группы {groupId} на {date.ToShortDateString()}:");
|
||||||
|
foreach (var presence in presences)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"User: {presence.UserGuid}, Attended: {presence.IsAttedance}, Lesson: {presence.LessonNumber}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void MarkUserAsAbsent()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите GUID пользователя:");
|
||||||
|
if (Guid.TryParse(Console.ReadLine(), out var userGuid))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите номер первого занятия:");
|
||||||
|
if (int.TryParse(Console.ReadLine(), out int startLesson))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите номер последнего занятия:");
|
||||||
|
if (int.TryParse(Console.ReadLine(), out int endLesson))
|
||||||
|
{
|
||||||
|
_useCasePresence.MarkUserAsAbsent(userGuid, startLesson, endLesson);
|
||||||
|
Console.WriteLine("Пользователь отмечен как отсутствующий.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный номер последнего занятия.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный номер первого занятия.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный GUID.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void GenerateDailySchedule()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите ID группы:");
|
||||||
|
if (int.TryParse(Console.ReadLine(), out int groupId))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите номер первого урока:");
|
||||||
|
if (int.TryParse(Console.ReadLine(), out int startLesson))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Введите номер последнего урока:");
|
||||||
|
if (int.TryParse(Console.ReadLine(), out int endLesson))
|
||||||
|
{
|
||||||
|
_useCasePresence.GenerateDailySchedule(groupId, startLesson, endLesson);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный номер последнего урока.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный номер первого урока.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Некорректный ID группы.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user