init
This commit is contained in:
parent
d3fed9e925
commit
bdcbb23022
@ -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; }
|
||||
|
||||
|
@ -14,5 +14,6 @@ namespace Demo.Data.Repository
|
||||
|
||||
List<PresenceLocalEntity> GetPresenceByDateAndGroup(DateTime date, int groupId);
|
||||
void SavePresence(List<PresenceLocalEntity> presences);
|
||||
List<PresenceLocalEntity> GetPresenceByGroup(int groupId);
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,9 @@ namespace Demo.Data.Repository
|
||||
|
||||
public PresenceRepositoryImpl()
|
||||
{
|
||||
_presences = LocalStaticData.presences;
|
||||
_presences = new List<PresenceLocalEntity>(); // Ваши реальные данные
|
||||
}
|
||||
|
||||
// Метод для сохранения посещаемости
|
||||
public void SavePresence(List<PresenceLocalEntity> presences)
|
||||
{
|
||||
foreach (var presence in presences)
|
||||
@ -31,27 +30,32 @@ namespace Demo.Data.Repository
|
||||
}
|
||||
else
|
||||
{
|
||||
// Обновление существующего значения посещаемости
|
||||
existingPresence.IsAttedance = presence.IsAttedance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Метод для получения всех дат посещаемости по группе
|
||||
public List<DateTime> 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<PresenceLocalEntity> 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<PresenceLocalEntity> 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<PresenceLocalEntity> GetPresenceByGroup(int groupId)
|
||||
{
|
||||
return _presences.Where(p => p.GroupId == groupId).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -47,9 +47,8 @@ namespace Demo.Domain.UseCase
|
||||
// Метод для получения списка всех групп
|
||||
public List<Group> 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<Group> 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())
|
||||
{
|
||||
|
@ -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<PresenceLocalEntity> GetAllPresenceByGroup(int groupId)
|
||||
{
|
||||
return _presenceRepository.GetPresenceByGroup(groupId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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")]
|
||||
|
@ -1 +1 @@
|
||||
5088e77b146ea464a1056f1261a0d0e4064405ca4080bc9ab4bf224a506ec90b
|
||||
1cf2463240a142c158bbf3e4a5d38c80b92a269d698158a042fab304bc559eb0
|
||||
|
@ -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 =
|
||||
|
Binary file not shown.
@ -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
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
94d3c7dec603eb068976231f8e3f6b7262a20ec3a72c6546c0039fab9f6d5f66
|
||||
2a3bf560e37aadfd842e18f17d390e03663433c2a3d00db706813132cb93d702
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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": {
|
||||
|
@ -5,11 +5,11 @@
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\adm\.nuget\packages\</NuGetPackageFolders>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\prdb\.nuget\packages\</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.11.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\adm\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Users\prdb\.nuget\packages\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -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": {
|
||||
|
@ -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": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user