проект 5 #1

Open
Bricksoul wants to merge 2 commits from develop into master
29 changed files with 1108 additions and 65 deletions

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Demo.domain.Models namespace Demo.Data.Entity
{ {
public class GroupLocalEntity public class GroupLocalEntity
{ {

View File

@ -4,12 +4,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Demo.domain.Models namespace Demo.Data.Entity
{ {
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; }
public required DateOnly Date { get; set; } public required DateOnly Date { get; set; }
public required int LessonNumber { get; set; } public required int LessonNumber { get; set; }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Demo.domain.Models namespace Demo.Data.Entity
{ {
public class UserLocalEnity : IEquatable<UserLocalEnity> public class UserLocalEnity : IEquatable<UserLocalEnity>
{ {
@ -18,7 +18,7 @@ namespace Demo.domain.Models
public bool Equals(UserLocalEnity? other) public bool Equals(UserLocalEnity? other)
{ {
if (other == null) return false; if (other == null) return false;
return this.Guid.Equals(other.Guid); return Guid.Equals(other.Guid);
} }
} }
} }

View File

@ -1,4 +1,4 @@
using Demo.domain.Models; using Demo.Data.Entity;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -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 },
};
} }
} }

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace Demo.Data.RemoteData.RemoteDataBase.DAO
{
public class GroupDao
{
public int Id { get; set; } // Обратите внимание на заглавную букву
public required string Name { get; set; }
public IEnumerable<UserDao> Users { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.Data.RemoteData.RemoteDataBase.DAO
{
public class PresenceDao
{
public Guid UserGuid { get; set; }
public bool IsAttedance { get; set; }
public DateOnly Date { get; set; }
public int LessonNumber { get; set; }
public UserDao UserDao { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.Data.RemoteData.RemoteDataBase.DAO
{
public class UserDao
{
public required string F10 { get; set; }
public Guid Guid { get; set; }
public required int GroupId { get; set; }
public GroupDao Group { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore;
using Npgsql;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
using Demo.domain.Models;
namespace Demo.Data.RemoteData.RemoteDataBase
{
public class RemoteDatabaseContex : DbContext
{
public DbSet<GroupDao> Groups {get; set;}
public DbSet<UserDao> Users {get; set;}
public DbSet<PresenceDao> PresenceDaos {get; set;}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5421;Username=user9;Database=user9;Password=X8C8NTnD;");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<GroupDao>().HasKey(group => group.Id);
modelBuilder.Entity<GroupDao>().Property(group => group.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<UserDao>().HasKey(user => user.Guid);
modelBuilder.Entity<UserDao>().Property(user => user.Guid).ValueGeneratedOnAdd();
modelBuilder.Entity <PresenceDao>().HasKey(presence =>new
{
presence.UserGuid,
presence.Date,
presence.IsAttedance,
presence.LessonNumber
});
}
}
}

View File

@ -1,4 +1,5 @@
using Demo.Data.LocalData; using Demo.Data.Entity;
using Demo.Data.LocalData;
using Demo.domain.Models; using Demo.domain.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -48,14 +49,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;
} }
} }
} }

View File

@ -1,19 +1,13 @@
using Demo.domain.Models; using Demo.Data.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.Data.Repository 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 UpdateGroupById(int groupId, GroupLocalEntity updatedGroup);
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup); bool RemoveGroupById(int groupId);
} }
} }

View File

@ -0,0 +1,11 @@
using Demo.Data.Entity;
using System.Collections.Generic;
namespace Demo.Data.Repository
{
public interface IPresenceRepository
{
bool AddPresence(PresenceLocalEntity newPresence);
List<PresenceLocalEntity> GetAllPresences();
}
}

View File

@ -0,0 +1,14 @@
using Demo.Data.Entity;
using System.Collections.Generic;
namespace Demo.Data.Repository
{
public interface IUserRepository
{
bool AddUser(UserLocalEnity newUser);
List<UserLocalEnity> GetAllUsers();
UserLocalEnity GetUserById(Guid userID);
bool RemoveUserById(Guid userID);
bool UpdateUserById(Guid userID, UserLocalEnity updatedUser);
}
}

View File

@ -0,0 +1,90 @@
using Demo.Data.Entity;
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
class SQLGroupRepositoryLmpl : IGroupRepository
{
private readonly RemoteDatabaseContex _remoteDatabaseContext;
public SQLGroupRepositoryLmpl(RemoteDatabaseContex remoteDatabaseContext)
{
_remoteDatabaseContext = remoteDatabaseContext;
}
public bool AddGroup(GroupLocalEntity newGroup)
{
GroupDao groupDao = new GroupDao { Name = newGroup.Name };
var result = _remoteDatabaseContext.Groups.Add(groupDao);
_remoteDatabaseContext.SaveChanges();
if (result != null) return true;
return false;
}
public List<GroupLocalEntity> GetAllGroup()
{
var groups = _remoteDatabaseContext.Groups.ToList();
return groups.Select(g => new GroupLocalEntity
{
Id = g.Id,
Name = g.Name
}).ToList();
}
public GroupLocalEntity GetGroupById(int groupID)
{
var group = _remoteDatabaseContext.Groups
.FirstOrDefault(g => g.Id == groupID);
if (group == null)
{
return null;
}
return new GroupLocalEntity
{
Id = group.Id,
Name = group.Name
};
}
public bool RemoveGroupById(int groupID)
{
var group = _remoteDatabaseContext.Groups
.FirstOrDefault(g => g.Id == groupID);
if (group == null)
{
return false;
}
_remoteDatabaseContext.Groups.Remove(group);
_remoteDatabaseContext.SaveChanges();
return true;
}
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
{
var existingGroup = _remoteDatabaseContext.Groups
.FirstOrDefault(g => g.Id == groupID);
if (existingGroup == null)
{
return false;
}
existingGroup.Name = updatedGroup.Name;
_remoteDatabaseContext.SaveChanges();
return true;
}
}
}

View File

@ -0,0 +1,45 @@
using Demo.Data.Entity;
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
public class SQLPresenceRepositoryImpl : IPresenceRepository
{
private readonly RemoteDatabaseContex _remoteDatabaseContext;
public SQLPresenceRepositoryImpl(RemoteDatabaseContex remoteDatabaseContext)
{
_remoteDatabaseContext = remoteDatabaseContext;
}
public bool AddPresence(PresenceLocalEntity newPresence)
{
var presenceDao = new PresenceDao
{
UserGuid = newPresence.UserGuid,
IsAttedance = newPresence.IsAttedance, // Используем IsAttendance
Date = newPresence.Date,
LessonNumber = newPresence.LessonNumber
};
_remoteDatabaseContext.PresenceDaos.Add(presenceDao);
return _remoteDatabaseContext.SaveChanges() > 0; // Возвращаем true, если изменения сохранены
}
public List<PresenceLocalEntity> GetAllPresences()
{
return _remoteDatabaseContext.PresenceDaos
.Select(p => new PresenceLocalEntity
{
UserGuid = p.UserGuid,
IsAttedance = p.IsAttedance, // Обратите внимание на правильное название свойства
Date = p.Date,
LessonNumber = p.LessonNumber
})
.ToList();
}
}
}

View File

@ -0,0 +1,94 @@
using Demo.Data.Entity;
using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.RemoteData.RemoteDataBase.DAO;
using System.Collections.Generic;
using System.Linq;
namespace Demo.Data.Repository
{
public class SQLUserRepositoryImpl : IUserRepository
{
private readonly RemoteDatabaseContex _remoteDatabaseContext;
public SQLUserRepositoryImpl(RemoteDatabaseContex remoteDatabaseContext)
{
_remoteDatabaseContext = remoteDatabaseContext;
}
public bool AddUser(UserLocalEnity newUser)
{
var userDao = new UserDao
{
Guid = Guid.NewGuid(),
F10 = newUser.FIO,
GroupId = newUser.GroupID
};
_remoteDatabaseContext.Users.Add(userDao);
return _remoteDatabaseContext.SaveChanges() > 0;
}
public List<UserLocalEnity> GetAllUsers()
{
return _remoteDatabaseContext.Users
.Select(user => new UserLocalEnity
{
Guid = user.Guid,
FIO = user.F10,
GroupID = user.GroupId
})
.ToList();
}
public UserLocalEnity GetUserById(Guid userID)
{
var user = _remoteDatabaseContext.Users.Find(userID);
if (user == null)
{
return null;
}
return new UserLocalEnity
{
Guid = user.Guid,
GroupID = user.GroupId,
FIO = user.F10
};
}
public bool RemoveUserById(Guid userID)
{
var user = _remoteDatabaseContext.Users.Find(userID);
if (user == null)
{
return false;
}
_remoteDatabaseContext.Users.Remove(user);
_remoteDatabaseContext.SaveChanges();
return true;
}
public bool UpdateUserById(Guid userID, UserLocalEnity updatedUser)
{
var user = _remoteDatabaseContext.Users.Find(userID);
if (user == null)
{
return false;
}
user.GroupId = updatedUser.GroupID;
user.Guid = updatedUser.Guid;
_remoteDatabaseContext.SaveChanges();
return true;
}
}
}

View File

@ -1,5 +1,5 @@
using Demo.Data.LocalData; using Demo.Data.Entity;
using Demo.domain.Models; using Demo.Data.LocalData;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -8,7 +8,17 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Data\RemoteData\" /> <Folder Include="Data\RemoteData\RemoteApi\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,5 @@
using Demo.Data.LocalData; using Demo.Data.Entity;
using Demo.Data.LocalData;
using Demo.Data.Repository; using Demo.Data.Repository;
using Demo.domain.Models; using Demo.domain.Models;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,15 +9,15 @@ namespace Demo.Domain.UseCase
{ {
public class GroupUseCase public class GroupUseCase
{ {
private GroupRepositoryImpl _repositoryGroupImpl; private IGroupRepository _repositoryGroupImpl;
public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl) public GroupUseCase(IGroupRepository repositoryGroupImpl)
{ {
_repositoryGroupImpl = repositoryGroupImpl; _repositoryGroupImpl = repositoryGroupImpl;
} }
public bool RemoveGroupById(int groupID) public bool RemoveGroupById(int groupID)
{ {
var group = _repositoryGroupImpl.GetAllGroups.FirstOrDefault(g => g.Id == groupID); var group = _repositoryGroupImpl.GetAllGroup().FirstOrDefault(g => g.Id == groupID);
if (group != null) if (group != null)
{ {
_repositoryGroupImpl.RemoveGroupById(groupID); _repositoryGroupImpl.RemoveGroupById(groupID);
@ -30,7 +31,7 @@ namespace Demo.Domain.UseCase
public bool AddGroup(GroupLocalEntity group) public bool AddGroup(GroupLocalEntity group)
{ {
// Если метод возвращает true, то группа добавлена успешно
return _repositoryGroupImpl.AddGroup(group); return _repositoryGroupImpl.AddGroup(group);
} }

View 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;
}
}
}

View File

@ -0,0 +1,72 @@
using Demo.Data.Entity;
using Demo.Data.LocalData;
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, DateTime date)
{
var usersInGroup = LocalStaticData.users
.Where(u => u.GroupID == groupId)
.ToList();
LocalStaticData.presences.RemoveAll(p => usersInGroup.Select(users => users.Guid).Contains(p.UserGuid) && p.Date == DateOnly.FromDateTime(date));
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(date),
LessonNumber = lesson
};
LocalStaticData.presences.Add(presence);
Console.WriteLine($"User: {user.Guid}, Attended: {presence.IsAttedance}, Date: {presence.Date}, Lesson: {presence.LessonNumber}");
}
}
}
public void GenerateWeeklySchedule(int groupId, int startLesson, int endLesson, DateTime date)
{
for(int i = 0; i < 7;i++)
{
GenerateDailySchedule(groupId, startLesson, endLesson, date.AddDays(i));
}
}
}
}

View File

@ -1,4 +1,5 @@
using Demo.Data.Repository; using Demo.Data.Entity;
using Demo.Data.Repository;
using Demo.domain.Models; using Demo.domain.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,11 +9,11 @@ namespace Demo.Domain.UseCase
{ {
public class UserUseCase public class UserUseCase
{ {
private readonly UserRepositoryImpl _repositoryUserImpl; private readonly IUserRepository _repositoryUserImpl;
private readonly IGroupRepository _repositoryGroupImpl; private readonly IGroupRepository _repositoryGroupImpl;
public UserUseCase(UserRepositoryImpl repositoryImpl, IGroupRepository repositoryGroupImpl) public UserUseCase(IUserRepository repositoryImpl, IGroupRepository repositoryGroupImpl)
{ {
_repositoryUserImpl = repositoryImpl; _repositoryUserImpl = repositoryImpl;
_repositoryGroupImpl = repositoryGroupImpl; _repositoryGroupImpl = repositoryGroupImpl;
@ -21,7 +22,7 @@ namespace Demo.Domain.UseCase
private List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroup() private List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroup()
.Select(it => new Group { Id = it.Id, Name = it.Name }).ToList(); .Select(it => new Group { Id = it.Id, Name = it.Name }).ToList();
public List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers public List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers()
.Join(_repositoryGroupImpl.GetAllGroup(), .Join(_repositoryGroupImpl.GetAllGroup(),
user => user.GroupID, user => user.GroupID,
group => group.Id, group => group.Id,
@ -31,22 +32,22 @@ namespace Demo.Domain.UseCase
public bool RemoveUserByGuid(Guid userGuid) public bool RemoveUserByGuid(Guid userGuid)
{ {
return _repositoryUserImpl.RemoveUserByGuid(userGuid); return _repositoryUserImpl.RemoveUserById(userGuid);
} }
public User UpdateUser(User user) public User UpdateUser(Guid userGuid,User user)
{ {
UserLocalEnity userLocalEnity = new UserLocalEnity { FIO = user.FIO, GroupID = user.Group.Id, Guid = user.Guid }; UserLocalEnity userLocalEnity = new UserLocalEnity { FIO = user.FIO, GroupID = user.Group.Id, Guid = user.Guid };
UserLocalEnity? result = _repositoryUserImpl.UpdateUser(userLocalEnity); bool result = _repositoryUserImpl.UpdateUserById(userGuid, userLocalEnity);
if (result == null) throw new Exception(""); if (!result) throw new Exception("");
Group? group = GetAllGroups().FirstOrDefault(it => it.Id == result!.GroupID); Group? group = GetAllGroups().FirstOrDefault(it => it.Id == user.Group.Id);
if (group == null) throw new Exception(""); if (group == null) throw new Exception("");
return new User { FIO = user.FIO, Guid = user.Guid, Group = group }; return new User { FIO = user.FIO, Guid = user.Guid, Group = group };
} }
public User? FindUserByGuid(Guid userGuid) public User? FindUserByGuid(Guid userGuid)
{ {
var userLocal = _repositoryUserImpl.GetUserByGuid(userGuid); var userLocal = _repositoryUserImpl.GetUserById(userGuid);
if (userLocal == null) return null; if (userLocal == null) return null;
var group = _repositoryGroupImpl.GetAllGroup().FirstOrDefault(g => g.Id == userLocal.GroupID); var group = _repositoryGroupImpl.GetAllGroup().FirstOrDefault(g => g.Id == userLocal.GroupID);

View File

@ -0,0 +1,118 @@
// <auto-generated />
using System;
using Demo.Data.RemoteData.RemoteDataBase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Demo.Migrations
{
[DbContext(typeof(RemoteDatabaseContex))]
[Migration("20241028123800_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Groups");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
{
b.Property<Guid>("UserGuid")
.HasColumnType("uuid");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<bool>("IsAttedance")
.HasColumnType("boolean");
b.Property<int>("LessonNumber")
.HasColumnType("integer");
b.Property<Guid>("UserDaoGuid")
.HasColumnType("uuid");
b.HasKey("UserGuid", "Date", "IsAttedance", "LessonNumber");
b.HasIndex("UserDaoGuid");
b.ToTable("PresenceDaos");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
{
b.Property<Guid>("Guid")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("F10")
.IsRequired()
.HasColumnType("text");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasIndex("GroupId");
b.ToTable("Users");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
{
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", "UserDao")
.WithMany()
.HasForeignKey("UserDaoGuid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserDao");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
{
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", "Group")
.WithMany("Users")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
{
b.Navigation("Users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,92 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Demo.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Groups",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Groups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Guid = table.Column<Guid>(type: "uuid", nullable: false),
F10 = table.Column<string>(type: "text", nullable: false),
GroupId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Guid);
table.ForeignKey(
name: "FK_Users_Groups_GroupId",
column: x => x.GroupId,
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PresenceDaos",
columns: table => new
{
UserGuid = table.Column<Guid>(type: "uuid", nullable: false),
IsAttedance = table.Column<bool>(type: "boolean", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
LessonNumber = table.Column<int>(type: "integer", nullable: false),
UserDaoGuid = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PresenceDaos", x => new { x.UserGuid, x.Date, x.IsAttedance, x.LessonNumber });
table.ForeignKey(
name: "FK_PresenceDaos_Users_UserDaoGuid",
column: x => x.UserDaoGuid,
principalTable: "Users",
principalColumn: "Guid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PresenceDaos_UserDaoGuid",
table: "PresenceDaos",
column: "UserDaoGuid");
migrationBuilder.CreateIndex(
name: "IX_Users_GroupId",
table: "Users",
column: "GroupId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PresenceDaos");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "Groups");
}
}
}

View File

@ -0,0 +1,115 @@
// <auto-generated />
using System;
using Demo.Data.RemoteData.RemoteDataBase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Demo.Migrations
{
[DbContext(typeof(RemoteDatabaseContex))]
partial class RemoteDatabaseContexModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Groups");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
{
b.Property<Guid>("UserGuid")
.HasColumnType("uuid");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<bool>("IsAttedance")
.HasColumnType("boolean");
b.Property<int>("LessonNumber")
.HasColumnType("integer");
b.Property<Guid>("UserDaoGuid")
.HasColumnType("uuid");
b.HasKey("UserGuid", "Date", "IsAttedance", "LessonNumber");
b.HasIndex("UserDaoGuid");
b.ToTable("PresenceDaos");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
{
b.Property<Guid>("Guid")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("F10")
.IsRequired()
.HasColumnType("text");
b.Property<int>("GroupId")
.HasColumnType("integer");
b.HasKey("Guid");
b.HasIndex("GroupId");
b.ToTable("Users");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b =>
{
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", "UserDao")
.WithMany()
.HasForeignKey("UserDaoGuid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("UserDao");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b =>
{
b.HasOne("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", "Group")
.WithMany("Users")
.HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Group");
});
modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.GroupDao", b =>
{
b.Navigation("Users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,16 +1,29 @@
using Demo.Data.Repository; using Demo.Data.RemoteData.RemoteDataBase;
using Demo.Data.Repository;
using Demo.Domain.UseCase; using Demo.Domain.UseCase;
using Demo.UI; using Demo.UI;
using Microsoft.Extensions.DependencyInjection;
class Program class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl);
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase); IServiceCollection services = new ServiceCollection();
services.AddDbContext<RemoteDatabaseContex>()
.AddSingleton<IGroupRepository, SQLGroupRepositoryLmpl>()
.AddSingleton<IUserRepository, SQLUserRepositoryImpl>()
.AddSingleton<IPresenceRepository, SQLPresenceRepositoryImpl>()
.AddSingleton<GroupUseCase>()
.AddSingleton<UseCaseGeneratePresence>()
.AddSingleton<UserUseCase>()
.AddSingleton<UseCasePresence>()
.AddSingleton<UserConsoleUI>()
.AddSingleton<PresenceConsoleUI>()
.AddSingleton<GroupConsoleUI>()
.AddSingleton<MainMenuUI>();
var serviceProvaider = services.BuildServiceProvider();
MainMenuUI mainMenuUI= serviceProvaider.GetService<MainMenuUI>();
mainMenuUI.DisplayMenu();
} }
} }

View File

@ -1,4 +1,5 @@
using Demo.Data.LocalData; using Demo.Data.Entity;
using Demo.Data.LocalData;
using Demo.domain.Models; using Demo.domain.Models;
using Demo.Domain.UseCase; using Demo.Domain.UseCase;
using System; using System;

View File

@ -8,15 +8,18 @@ namespace Demo.UI
{ {
private UserConsoleUI _userConsoleUI; private UserConsoleUI _userConsoleUI;
private GroupConsoleUI _groupConsoleUI; private GroupConsoleUI _groupConsoleUI;
private UseCasePresence _presenceUseCase;
private PresenceConsoleUI _presenceConsoleUI;
public MainMenuUI(UserUseCase userUseCase, GroupUseCase groupUseCase) public MainMenuUI(UserConsoleUI userConsoleUI, GroupConsoleUI groupConsoleUI, PresenceConsoleUI presenceConsoleUI)
{ {
_userConsoleUI = new UserConsoleUI(userUseCase); _userConsoleUI = userConsoleUI;
_groupConsoleUI = new GroupConsoleUI(groupUseCase); _groupConsoleUI = groupConsoleUI;
DisplayMenu(); _presenceConsoleUI = presenceConsoleUI;
} }
private void DisplayMenu()
public void DisplayMenu()
{ {
while (true) while (true)
{ {
@ -29,6 +32,11 @@ 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("13 - Генерация расписания по диапозону на неделю");
Console.WriteLine("0 - Выход"); Console.WriteLine("0 - Выход");
var input = Console.ReadLine(); var input = Console.ReadLine();
@ -65,7 +73,7 @@ namespace Demo.UI
Group = new Group { Id = newGroupId, Name = newGroupName } Group = new Group { Id = newGroupId, Name = newGroupName }
}; };
_userConsoleUI.UpdateUser(updatedUser); _userConsoleUI.UpdateUser(updateGuid, updatedUser);
} }
else else
{ {
@ -108,6 +116,76 @@ 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":
Console.WriteLine("Введите GUID пользователя для отметки отсутствия:");
if (Guid.TryParse(Console.ReadLine(), out var absenceUserGuid))
{
Console.WriteLine("Введите дату (в формате ГГГГ-ММ-ДД):");
if (DateOnly.TryParse(Console.ReadLine(), out var absenceDate))
{
Console.WriteLine("Введите диапазон уроков (например, 2-4):");
var lessonRange = Console.ReadLine().Split('-');
if (lessonRange.Length == 2 &&
int.TryParse(lessonRange[0], out var startLesson) &&
int.TryParse(lessonRange[1], out var endLesson))
{
// Вызов метода для отметки отсутствия
_presenceConsoleUI.MarkUserAsAbsent(absenceUserGuid, absenceDate, startLesson, endLesson);
}
else
{
Console.WriteLine("Некорректный диапазон уроков.");
}
}
else
{
Console.WriteLine("Некорректная дата.");
}
}
else
{
Console.WriteLine("Некорректный GUID.");
}
break;
case "12":
_presenceConsoleUI.GenerateDailySchedule();
break;
case "13":
_presenceConsoleUI.GenerateWeeklySchedule();
break;
case "0": case "0":
return; return;
default: default:

120
Demo/UI/PresenceConcole.cs Normal file
View File

@ -0,0 +1,120 @@
using Demo.Data.Entity;
using Demo.Data.LocalData;
using Demo.domain.Models;
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(Guid userGuid, DateOnly date, int startLesson, int endLesson)
{
_useCasePresence.MarkUserAsAbsent(userGuid, startLesson, endLesson);
for (int lesson = startLesson; lesson <= endLesson; lesson++)
{
var presence = new PresenceLocalEntity
{
UserGuid = userGuid,
IsAttedance = false,
Date = date,
LessonNumber = lesson
};
// Вывод информации о отметке
Console.WriteLine($"User: {userGuid}, Attended: {presence.IsAttedance}, Date: {presence.Date}, Lesson: {presence.LessonNumber}");
}
}
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,DateTime.Now);
}
else
{
Console.WriteLine("Некорректный номер последнего урока.");
}
}
else
{
Console.WriteLine("Некорректный номер первого урока.");
}
}
else
{
Console.WriteLine("Некорректный ID группы.");
}
}
public void GenerateWeeklySchedule()
{
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.GenerateWeeklySchedule(groupId, startLesson, endLesson, DateTime.Now);
}
else
{
Console.WriteLine("Некорректный номер последнего урока.");
}
}
else
{
Console.WriteLine("Некорректный номер первого урока.");
}
}
else
{
Console.WriteLine("Некорректный ID группы.");
}
}
}
}

View File

@ -43,9 +43,9 @@ namespace Demo.UI
} }
} }
public void UpdateUser(User updatedUser) public void UpdateUser(Guid userGuid, User updatedUser)
{ {
var result = _userUseCase.UpdateUser(updatedUser); var result = _userUseCase.UpdateUser(userGuid, updatedUser);
if (result != null) if (result != null)
{ {
Console.WriteLine("Пользователь обновлён."); Console.WriteLine("Пользователь обновлён.");