diff --git a/Demo/Data/LocalData/Entity/Presence.cs b/Demo/Data/LocalData/Entity/Presence.cs index 91e7937..4c3a1c6 100644 --- a/Demo/Data/LocalData/Entity/Presence.cs +++ b/Demo/Data/LocalData/Entity/Presence.cs @@ -9,6 +9,7 @@ namespace Demo.domain.Models public class PresenceLocalEntity { public required int UserId { get; set; } + public required int GroupId { get; set; } public bool IsAttedance { get; set; } = true; public required DateTime Date { get; set; } diff --git a/Demo/Data/Repository/IPresenceRepository.cs b/Demo/Data/Repository/IPresenceRepository.cs index df96c58..6ef7543 100644 --- a/Demo/Data/Repository/IPresenceRepository.cs +++ b/Demo/Data/Repository/IPresenceRepository.cs @@ -14,5 +14,6 @@ namespace Demo.Data.Repository List GetPresenceByDateAndGroup(DateTime date, int groupId); void SavePresence(List presences); + List GetPresenceByGroup(int groupId); } } diff --git a/Demo/Data/Repository/PresenceRepositoryImpl.cs b/Demo/Data/Repository/PresenceRepositoryImpl.cs index 725bf3a..59420c7 100644 --- a/Demo/Data/Repository/PresenceRepositoryImpl.cs +++ b/Demo/Data/Repository/PresenceRepositoryImpl.cs @@ -12,10 +12,9 @@ namespace Demo.Data.Repository public PresenceRepositoryImpl() { - _presences = LocalStaticData.presences; + _presences = new List(); // Ваши реальные данные } - // Метод для сохранения посещаемости public void SavePresence(List presences) { foreach (var presence in presences) @@ -31,27 +30,32 @@ namespace Demo.Data.Repository } else { - // Обновление существующего значения посещаемости existingPresence.IsAttedance = presence.IsAttedance; } } } - // Метод для получения всех дат посещаемости по группе - public List GetAllDatesByGroup(int groupId) - { - return _presences - .Where(p => LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)) - .Select(p => p.Date.Date) - .Distinct() - .ToList(); - } - - // Метод для получения посещаемости по дате и группе public List GetPresenceByDateAndGroup(DateTime date, int groupId) { return _presences.Where(p => p.Date.Date == date.Date && LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)).ToList(); } + + // Реализация метода для получения всех данных по группе + public List GetAllPresenceByGroup(int groupId) + { + return _presences + .Where(p => LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)) + .OrderBy(p => p.Date) + .ThenBy(p => p.LessonNumber) + .ToList(); + } + + + public List GetPresenceByGroup(int groupId) + { + return _presences.Where(p => p.GroupId == groupId).ToList(); + } + } } diff --git a/Demo/Domain/Models/Presence.cs b/Demo/Domain/Models/Presence.cs index 7dbe122..5561dfe 100644 --- a/Demo/Domain/Models/Presence.cs +++ b/Demo/Domain/Models/Presence.cs @@ -10,6 +10,7 @@ namespace Demo.domain.Models { public required User User { get; set; } + public required int GroupId { get; set; } public bool IsAttedance { get; set; } = true; public required DateTime Date { get; set; } diff --git a/Demo/Domain/UseCase/GroupUseCase.cs b/Demo/Domain/UseCase/GroupUseCase.cs index 1b39ef0..d7c5a41 100644 --- a/Demo/Domain/UseCase/GroupUseCase.cs +++ b/Demo/Domain/UseCase/GroupUseCase.cs @@ -47,9 +47,8 @@ namespace Demo.Domain.UseCase // Метод для получения списка всех групп public List GetAllGroups() { - return _repositoryGroupImpl.GetAllGroups() - .Select(it => new Group { Id = it.Id, Name = it.Name }) - .ToList(); + return [.. _repositoryGroupImpl.GetAllGroups() + .Select(it => new Group { Id = it.Id, Name = it.Name })]; } @@ -57,9 +56,13 @@ namespace Demo.Domain.UseCase { List GetAllGroups() { - return _repositoryGroupImpl.GetAllGroups() - .Select(it => new Group { Id = it.Id, Name = it.Name }) - .ToList(); + return [.. _repositoryGroupImpl + .GetAllGroups() + .Select( + it => new Group + { Id = it.Id, Name = it.Name } + ) + ]; } foreach(var group in GetAllGroups()) { diff --git a/Demo/Domain/UseCase/UseCaseGeneratePresence.cs b/Demo/Domain/UseCase/UseCaseGeneratePresence.cs index 6c3647f..0660607 100644 --- a/Demo/Domain/UseCase/UseCaseGeneratePresence.cs +++ b/Demo/Domain/UseCase/UseCaseGeneratePresence.cs @@ -38,6 +38,7 @@ namespace Demo.Domain.UseCase presences.Add(new PresenceLocalEntity { UserId = user.ID, + GroupId = user.GroupID, Date = currentDate, LessonNumber = lessonNumber, IsAttedance = true @@ -71,5 +72,13 @@ namespace Demo.Domain.UseCase + public List GetAllPresenceByGroup(int groupId) + { + return _presenceRepository.GetPresenceByGroup(groupId); + } + + + + } } diff --git a/Demo/UI/MainMenu.cs b/Demo/UI/MainMenu.cs index 8c9a227..46afea7 100644 --- a/Demo/UI/MainMenu.cs +++ b/Demo/UI/MainMenu.cs @@ -42,6 +42,7 @@ namespace Demo.UI Console.WriteLine("11. Сгенерировать посещаемость на неделю"); Console.WriteLine("12. Показать посещаемость"); Console.WriteLine("13. Отметить пользователя как отсутствующего"); + Console.WriteLine("14. Вывести всю посещаемость группы"); Console.WriteLine(); Console.WriteLine("0. Выход"); @@ -192,6 +193,13 @@ namespace Demo.UI Console.WriteLine("Пользователь отмечен как отсутствующий."); break; + case "14": + Console.Write("Введите ID группы: "); + int groupIdForAllPresence = int.Parse(Console.ReadLine()); + _presenceConsoleUI.DisplayAllPresenceByGroup(groupIdForAllPresence); + break; + + case "0": Console.WriteLine("Выход..."); return; diff --git a/Demo/UI/PresenceConsole.cs b/Demo/UI/PresenceConsole.cs index e49030b..d7a1529 100644 --- a/Demo/UI/PresenceConsole.cs +++ b/Demo/UI/PresenceConsole.cs @@ -19,7 +19,7 @@ namespace Demo.UI { try { - _presenceUseCase.GeneratePresenceDaily(firstLesson, lastLesson, groupId,date); + _presenceUseCase.GeneratePresenceDaily(firstLesson, lastLesson, groupId, date); Console.WriteLine("Посещаемость на день успешно сгенерирована."); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace Demo.UI if (a != presence.LessonNumber) { Console.WriteLine("---------------------------------------------"); - a=presence.LessonNumber; + a = presence.LessonNumber; } string status = presence.IsAttedance ? "Присутствует" : "Отсутствует"; Console.WriteLine($"Пользователь ID: {presence.UserId}, Занятие {presence.LessonNumber}: {status}"); @@ -82,5 +82,50 @@ namespace Demo.UI _presenceUseCase.MarkUserAbsentForLessons(userId, groupId, firstLesson, lastLesson, date); } + + + + public void DisplayAllPresenceByGroup(int groupId) + { + try + { + var presences = _presenceUseCase.GetAllPresenceByGroup(groupId); + + if (presences == null || !presences.Any()) + { + Console.WriteLine($"Посещаемость для группы с ID {groupId} отсутствует."); + return; + } + int a = presences[0].LessonNumber; + // Группируем по дате + var groupedPresences = presences.GroupBy(p => p.Date); // Предполагается, что есть поле Date в PresenceLocalEntity + + foreach (var group in groupedPresences) + { + Console.WriteLine("==================================================="); + Console.WriteLine($"Дата: {group.Key.ToString("dd.MM.yyyy")}"); // Форматирование даты + Console.WriteLine("==================================================="); + + foreach (var presence in group) + { + if (a != presence.LessonNumber) + { + Console.WriteLine("---------------------------------------------------"); + a= presence.LessonNumber; + } + string status = presence.IsAttedance ? "Присутствует" : "Отсутствует"; + Console.WriteLine($"Пользователь ID: {presence.UserId}, Занятие {presence.LessonNumber}: {status}"); + } + + Console.WriteLine("---------------------------------------------------"); + } + } + catch (Exception ex) + { + Console.WriteLine($"Ошибка при выводе посещаемости: {ex.Message}"); + } + } + + } } diff --git a/Demo/bin/Debug/net8.0/Demo.dll b/Demo/bin/Debug/net8.0/Demo.dll index b229e02..aa028b1 100644 Binary files a/Demo/bin/Debug/net8.0/Demo.dll and b/Demo/bin/Debug/net8.0/Demo.dll differ diff --git a/Demo/bin/Debug/net8.0/Demo.exe b/Demo/bin/Debug/net8.0/Demo.exe index 0a70b96..c11dcd3 100644 Binary files a/Demo/bin/Debug/net8.0/Demo.exe and b/Demo/bin/Debug/net8.0/Demo.exe differ diff --git a/Demo/bin/Debug/net8.0/Demo.pdb b/Demo/bin/Debug/net8.0/Demo.pdb index 95fd735..71db232 100644 Binary files a/Demo/bin/Debug/net8.0/Demo.pdb and b/Demo/bin/Debug/net8.0/Demo.pdb differ diff --git a/Demo/obj/Debug/net8.0/Demo.AssemblyInfo.cs b/Demo/obj/Debug/net8.0/Demo.AssemblyInfo.cs index 19f2c83..e986667 100644 --- a/Demo/obj/Debug/net8.0/Demo.AssemblyInfo.cs +++ b/Demo/obj/Debug/net8.0/Demo.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Demo")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+71b5a3c2837384ab3b6285a4c3d50906eb3b91cd")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d3fed9e9259a05c684c1994f05a91eda3c19c00b")] [assembly: System.Reflection.AssemblyProductAttribute("Demo")] [assembly: System.Reflection.AssemblyTitleAttribute("Demo")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache b/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache index 2a99c36..63eecb9 100644 --- a/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache +++ b/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache @@ -1 +1 @@ -5088e77b146ea464a1056f1261a0d0e4064405ca4080bc9ab4bf224a506ec90b +1cf2463240a142c158bbf3e4a5d38c80b92a269d698158a042fab304bc559eb0 diff --git a/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig b/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig index dc789ff..aeac96f 100644 --- a/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig +++ b/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig @@ -8,6 +8,6 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Demo -build_property.ProjectDir = C:\Users\adm\Source\Repos\presence_new\Demo\ +build_property.ProjectDir = C:\Users\prdb\source\repos\presence_new\Demo\ build_property.EnableComHosting = build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/Demo/obj/Debug/net8.0/Demo.assets.cache b/Demo/obj/Debug/net8.0/Demo.assets.cache index b6cded4..e3ecf99 100644 Binary files a/Demo/obj/Debug/net8.0/Demo.assets.cache and b/Demo/obj/Debug/net8.0/Demo.assets.cache differ diff --git a/Demo/obj/Debug/net8.0/Demo.csproj.FileListAbsolute.txt b/Demo/obj/Debug/net8.0/Demo.csproj.FileListAbsolute.txt index 62bc8d7..28366fd 100644 --- a/Demo/obj/Debug/net8.0/Demo.csproj.FileListAbsolute.txt +++ b/Demo/obj/Debug/net8.0/Demo.csproj.FileListAbsolute.txt @@ -12,3 +12,17 @@ C:\Users\adm\Source\Repos\presence_new\Demo\obj\Debug\net8.0\refint\Demo.dll C:\Users\adm\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.pdb C:\Users\adm\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.genruntimeconfig.cache C:\Users\adm\Source\Repos\presence_new\Demo\obj\Debug\net8.0\ref\Demo.dll +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.GeneratedMSBuildEditorConfig.editorconfig +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.AssemblyInfoInputs.cache +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.AssemblyInfo.cs +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.csproj.CoreCompileInputs.cache +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.dll +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\refint\Demo.dll +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.pdb +C:\Users\prdb\Source\Repos\presence_new\Demo\bin\Debug\net8.0\Demo.exe +C:\Users\prdb\Source\Repos\presence_new\Demo\bin\Debug\net8.0\Demo.deps.json +C:\Users\prdb\Source\Repos\presence_new\Demo\bin\Debug\net8.0\Demo.runtimeconfig.json +C:\Users\prdb\Source\Repos\presence_new\Demo\bin\Debug\net8.0\Demo.dll +C:\Users\prdb\Source\Repos\presence_new\Demo\bin\Debug\net8.0\Demo.pdb +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\Demo.genruntimeconfig.cache +C:\Users\prdb\Source\Repos\presence_new\Demo\obj\Debug\net8.0\ref\Demo.dll diff --git a/Demo/obj/Debug/net8.0/Demo.dll b/Demo/obj/Debug/net8.0/Demo.dll index b229e02..aa028b1 100644 Binary files a/Demo/obj/Debug/net8.0/Demo.dll and b/Demo/obj/Debug/net8.0/Demo.dll differ diff --git a/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache b/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache index 3708d5b..2f7772d 100644 --- a/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache +++ b/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache @@ -1 +1 @@ -94d3c7dec603eb068976231f8e3f6b7262a20ec3a72c6546c0039fab9f6d5f66 +2a3bf560e37aadfd842e18f17d390e03663433c2a3d00db706813132cb93d702 diff --git a/Demo/obj/Debug/net8.0/Demo.pdb b/Demo/obj/Debug/net8.0/Demo.pdb index 95fd735..71db232 100644 Binary files a/Demo/obj/Debug/net8.0/Demo.pdb and b/Demo/obj/Debug/net8.0/Demo.pdb differ diff --git a/Demo/obj/Debug/net8.0/apphost.exe b/Demo/obj/Debug/net8.0/apphost.exe index 0a70b96..c11dcd3 100644 Binary files a/Demo/obj/Debug/net8.0/apphost.exe and b/Demo/obj/Debug/net8.0/apphost.exe differ diff --git a/Demo/obj/Debug/net8.0/ref/Demo.dll b/Demo/obj/Debug/net8.0/ref/Demo.dll index 17cf4d2..b0edf02 100644 Binary files a/Demo/obj/Debug/net8.0/ref/Demo.dll and b/Demo/obj/Debug/net8.0/ref/Demo.dll differ diff --git a/Demo/obj/Debug/net8.0/refint/Demo.dll b/Demo/obj/Debug/net8.0/refint/Demo.dll index 17cf4d2..b0edf02 100644 Binary files a/Demo/obj/Debug/net8.0/refint/Demo.dll and b/Demo/obj/Debug/net8.0/refint/Demo.dll differ diff --git a/Demo/obj/Demo.csproj.nuget.dgspec.json b/Demo/obj/Demo.csproj.nuget.dgspec.json index ead427f..6f5d952 100644 --- a/Demo/obj/Demo.csproj.nuget.dgspec.json +++ b/Demo/obj/Demo.csproj.nuget.dgspec.json @@ -1,20 +1,20 @@ { "format": 1, "restore": { - "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj": {} + "C:\\Users\\prdb\\source\\repos\\presence_new\\Demo\\Demo.csproj": {} }, "projects": { - "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj": { + "C:\\Users\\prdb\\source\\repos\\presence_new\\Demo\\Demo.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", + "projectUniqueName": "C:\\Users\\prdb\\source\\repos\\presence_new\\Demo\\Demo.csproj", "projectName": "Demo", - "projectPath": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", - "packagesPath": "C:\\Users\\adm\\.nuget\\packages\\", - "outputPath": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\obj\\", + "projectPath": "C:\\Users\\prdb\\source\\repos\\presence_new\\Demo\\Demo.csproj", + "packagesPath": "C:\\Users\\prdb\\.nuget\\packages\\", + "outputPath": "C:\\Users\\prdb\\Source\\Repos\\presence_new\\Demo\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ - "C:\\Users\\adm\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Users\\prdb\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ @@ -22,6 +22,7 @@ ], "sources": { "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "C:\\Program Files\\dotnet\\library-packs": {}, "https://api.nuget.org/v3/index.json": {} }, "frameworks": { diff --git a/Demo/obj/Demo.csproj.nuget.g.props b/Demo/obj/Demo.csproj.nuget.g.props index b002ca2..faa1559 100644 --- a/Demo/obj/Demo.csproj.nuget.g.props +++ b/Demo/obj/Demo.csproj.nuget.g.props @@ -5,11 +5,11 @@ NuGet $(MSBuildThisFileDirectory)project.assets.json $(UserProfile)\.nuget\packages\ - C:\Users\adm\.nuget\packages\ + C:\Users\prdb\.nuget\packages\ PackageReference 6.11.0 - + \ No newline at end of file diff --git a/Demo/obj/project.assets.json b/Demo/obj/project.assets.json index 531e787..ae41933 100644 --- a/Demo/obj/project.assets.json +++ b/Demo/obj/project.assets.json @@ -8,19 +8,19 @@ "net8.0": [] }, "packageFolders": { - "C:\\Users\\adm\\.nuget\\packages\\": {} + "C:\\Users\\prdb\\.nuget\\packages\\": {} }, "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", + "projectUniqueName": "C:\\Users\\prdb\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", "projectName": "Demo", - "projectPath": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", - "packagesPath": "C:\\Users\\adm\\.nuget\\packages\\", - "outputPath": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\obj\\", + "projectPath": "C:\\Users\\prdb\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", + "packagesPath": "C:\\Users\\prdb\\.nuget\\packages\\", + "outputPath": "C:\\Users\\prdb\\Source\\Repos\\presence_new\\Demo\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ - "C:\\Users\\adm\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Users\\prdb\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ @@ -28,6 +28,7 @@ ], "sources": { "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "C:\\Program Files\\dotnet\\library-packs": {}, "https://api.nuget.org/v3/index.json": {} }, "frameworks": { diff --git a/Demo/obj/project.nuget.cache b/Demo/obj/project.nuget.cache index 1c21062..7bd4fa3 100644 --- a/Demo/obj/project.nuget.cache +++ b/Demo/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "eIAzK05HQQw=", + "dgSpecHash": "ai/Nx9dWPPA=", "success": true, - "projectFilePath": "C:\\Users\\adm\\Source\\Repos\\presence_new\\Demo\\Demo.csproj", + "projectFilePath": "C:\\Users\\prdb\\source\\repos\\presence_new\\Demo\\Demo.csproj", "expectedPackageFiles": [], "logs": [] } \ No newline at end of file