diff --git a/Demo/Data/LocalData/Entity/Group.cs b/Demo/Data/LocalData/Entity/Group.cs index d039987..506833b 100644 --- a/Demo/Data/LocalData/Entity/Group.cs +++ b/Demo/Data/LocalData/Entity/Group.cs @@ -8,7 +8,7 @@ namespace Demo.domain.Models { public class GroupLocalEntity { - public required int Id { get; set; } + public int Id { get; set; } public required string Name { get; set; } diff --git a/Demo/Data/RemoteData/RemoteDataBase/RemoteDatabaseContext.cs b/Demo/Data/RemoteData/RemoteDataBase/RemoteDatabaseContext.cs index 1472157..fd6aeae 100644 --- a/Demo/Data/RemoteData/RemoteDataBase/RemoteDatabaseContext.cs +++ b/Demo/Data/RemoteData/RemoteDataBase/RemoteDatabaseContext.cs @@ -18,7 +18,7 @@ namespace Demo.Data.RemoteData.RemoteDataBase protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseNpgsql(); + optionsBuilder.UseNpgsql("Host=localhost; Database=presencedb; Username=postgres; Password=123"); } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/Demo/Data/Repository/GroupRepositoryImpl.cs b/Demo/Data/Repository/GroupRepositoryImpl.cs index 67f588b..4c75bb6 100644 --- a/Demo/Data/Repository/GroupRepositoryImpl.cs +++ b/Demo/Data/Repository/GroupRepositoryImpl.cs @@ -37,48 +37,28 @@ public class GroupRepositoryImpl: IGroupRepository } // Метод для обновления существующей группы - public void UpdateGroup(GroupLocalEntity group) + public void UpdateGroupById(int groupId, GroupLocalEntity updatedGroup) { - var existingGroup = GetGroupById(group.Id); - if (existingGroup == null) throw new GroupNotFoundException(group.Id); + var existingGroup = GetGroupById(groupId); + if (existingGroup == null) throw new GroupNotFoundException(groupId); } - public void RemoveGroupById(GroupLocalEntity group) + public void RemoveGroupById(int groupId) { - var existingGroup = GetGroupById(group.Id); - if (existingGroup == null) throw new GroupNotFoundException(group.Id); + var existingGroup = GetGroupById(groupId); + if (existingGroup == null) throw new GroupNotFoundException(groupId); if (_groups.Contains(existingGroup)) { _groups.Remove(existingGroup); } } - public List GetAllGroup() + bool IGroupRepository.RemoveGroupById(int groupID) { throw new NotImplementedException(); } - public bool RemoveGroupById(int groupID) - { - throw new NotImplementedException(); - } - - public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) - { - throw new NotImplementedException(); - } - - bool IGroupRepository.AddGroup(GroupLocalEntity newGroup) - { - throw new NotImplementedException(); - } - - public List GetAllGroupDao() - { - throw new NotImplementedException(); - } - - public bool RemoveGroupByIdDao(int groupID) + List IGroupRepository.GetAllGroups() { throw new NotImplementedException(); } @@ -88,22 +68,12 @@ public class GroupRepositoryImpl: IGroupRepository throw new NotImplementedException(); } - public GroupDao GetGroupByIdDao(int groupID) + GroupDao IGroupRepository.GetGroupById(int groupID) { throw new NotImplementedException(); } - public bool AddGroup(GroupDao newGroup) - { - throw new NotImplementedException(); - } - - public bool UpdateGroupByIdDao(int groupID, GroupDao updatedGroup) - { - throw new NotImplementedException(); - } - - public bool AddGroupDao(GroupDao newGroup) + public bool AddGroup(string Name) { throw new NotImplementedException(); } diff --git a/Demo/Data/Repository/IGroupRepository.cs b/Demo/Data/Repository/IGroupRepository.cs index 20ab0e9..6eb3ab3 100644 --- a/Demo/Data/Repository/IGroupRepository.cs +++ b/Demo/Data/Repository/IGroupRepository.cs @@ -10,18 +10,10 @@ namespace Demo.Data.Repository { public interface IGroupRepository { - List GetAllGroup(); + List GetAllGroups(); bool RemoveGroupById(int groupID); - bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup); - GroupLocalEntity GetGroupById(int groupID); - bool AddGroup(GroupLocalEntity newGroup); - - - - List GetAllGroupDao(); - bool RemoveGroupByIdDao(int groupID); - bool UpdateGroupByIdDao(int groupID, GroupDao updatedGroup); - GroupDao GetGroupByIdDao(int groupID); - bool AddGroupDao(GroupDao newGroup); + bool UpdateGroupById(int groupID, GroupDao updatedGroup); + GroupDao GetGroupById(int groupID); + bool AddGroup(string Name); } } \ No newline at end of file diff --git a/Demo/Data/Repository/IPresenceRepository.cs b/Demo/Data/Repository/IPresenceRepository.cs index f3e1827..44fdd55 100644 --- a/Demo/Data/Repository/IPresenceRepository.cs +++ b/Demo/Data/Repository/IPresenceRepository.cs @@ -16,12 +16,5 @@ namespace Demo.Data.Repository List GetPresenceByDateAndGroup(DateTime date, int groupId); void SavePresence(List presences); List GetPresenceByGroup(int groupId); - - - - - List GetPresenceByDateAndGroupDao(DateTime date, int groupId); - void SavePresenceDao(List presences); - List GetPresenceByGroupDao(int groupId); } } diff --git a/Demo/Data/Repository/SQLGroupRepositoryImpl.cs b/Demo/Data/Repository/SQLGroupRepositoryImpl.cs index 5428d8a..5038163 100644 --- a/Demo/Data/Repository/SQLGroupRepositoryImpl.cs +++ b/Demo/Data/Repository/SQLGroupRepositoryImpl.cs @@ -18,7 +18,7 @@ namespace Demo.Data.Repository } // Метод для добавления новой группы - public bool AddGroupDao(GroupDao newGroup) + public bool AddGroup(GroupDao newGroup) { var groupDao = new GroupDao { @@ -30,7 +30,7 @@ namespace Demo.Data.Repository } // Метод для получения группы по ID - public GroupDao GetGroupByIdDao(int groupId) + public GroupDao GetGroupById(int groupId) { var groupDao = _remoteDatabaseContext.Groups .Include(g => g.Users) @@ -51,7 +51,7 @@ namespace Demo.Data.Repository } // Метод для получения всех групп - public List GetAllGroupDao() + public List GetAllGroups() { return _remoteDatabaseContext.Groups .Include(g => g.Users) @@ -70,7 +70,7 @@ namespace Demo.Data.Repository } // Метод для обновления группы по ID - public bool UpdateGroupByIdDao(int groupId, GroupDao updatedGroup) + public bool UpdateGroupById(int groupId, GroupDao updatedGroup) { var groupDao = _remoteDatabaseContext.Groups .Include(g => g.Users) @@ -91,7 +91,7 @@ namespace Demo.Data.Repository } // Метод для удаления группы по ID - public bool RemoveGroupByIdDao(int groupId) + public bool RemoveGroupById(int groupId) { var groupDao = _remoteDatabaseContext.Groups.Find(groupId); if (groupDao == null) return false; @@ -101,29 +101,22 @@ namespace Demo.Data.Repository return true; } - public List GetAllGroup() - { - throw new NotImplementedException(); - } - - public bool RemoveGroupById(int groupID) - { - throw new NotImplementedException(); - } - public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) { throw new NotImplementedException(); } - public GroupLocalEntity GetGroupById(int groupID) - { - throw new NotImplementedException(); - } - public bool AddGroup(GroupLocalEntity newGroup) + public bool AddGroup(string Name) { - throw new NotImplementedException(); + + var groupDao = new GroupDao + { + Name = Name + }; + _remoteDatabaseContext.Groups.Add(groupDao); + _remoteDatabaseContext.SaveChanges(); + return true; } } } diff --git a/Demo/Data/Repository/SQLPresenceRepository.cs b/Demo/Data/Repository/SQLPresenceRepository.cs index 8c7559f..5400cfd 100644 --- a/Demo/Data/Repository/SQLPresenceRepository.cs +++ b/Demo/Data/Repository/SQLPresenceRepository.cs @@ -27,7 +27,7 @@ namespace Demo.Data.Repository public List GetPresenceByDateAndGroupDao(DateTime date, int groupId) { return _remoteDatabaseContext.PresenceDaos.Where(p => p.Date == DateOnly.FromDateTime(date) && - LocalStaticData.users.Any(u => u.GroupID == groupId && u.ID == p.UserId)).ToList(); + _remoteDatabaseContext.Users.Any(u => u.GroupId == groupId && u.UserId == p.UserId)).ToList(); } public List GetPresenceByGroup(int groupId) diff --git a/Demo/Domain/UseCase/GroupUseCase.cs b/Demo/Domain/UseCase/GroupUseCase.cs index d7c5a41..f8d3f6f 100644 --- a/Demo/Domain/UseCase/GroupUseCase.cs +++ b/Demo/Domain/UseCase/GroupUseCase.cs @@ -1,13 +1,15 @@ using Demo.Data.LocalData; +using Demo.Data.RemoteData.RemoteDataBase.DAO; +using Demo.Data.Repository; using Demo.domain.Models; namespace Demo.Domain.UseCase { public class GroupUseCase { - private readonly GroupRepositoryImpl _repositoryGroupImpl; + private readonly IGroupRepository _repositoryGroupImpl; - public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl) + public GroupUseCase(IGroupRepository repositoryGroupImpl) { _repositoryGroupImpl = repositoryGroupImpl; } @@ -30,7 +32,7 @@ namespace Demo.Domain.UseCase } // Приватный метод для валидации существования группы по ID - private GroupLocalEntity ValidateGroupExistence(int groupId) + private GroupDao ValidateGroupExistence(int groupId) { var existingGroup = _repositoryGroupImpl.GetAllGroups() .FirstOrDefault(g => g.Id == groupId); @@ -79,17 +81,14 @@ namespace Demo.Domain.UseCase { ValidateGroupName(groupName); - var newId = _repositoryGroupImpl.GetAllGroups().Any() - ? _repositoryGroupImpl.GetAllGroups().Max(g => g.Id) + 1 - : 1; + GroupLocalEntity newGroup = new GroupLocalEntity { - Id = newId, Name = groupName }; - _repositoryGroupImpl.AddGroup(newGroup); + _repositoryGroupImpl.AddGroup(newGroup.Name); } public void RemoveGroupById(int groupId) @@ -103,7 +102,7 @@ namespace Demo.Domain.UseCase if (groupToRemove != null) { _groups.Remove(groupToRemove); - _repositoryGroupImpl.RemoveGroupById(existingGroup); + _repositoryGroupImpl.RemoveGroupById(existingGroup.Id); } else { @@ -120,7 +119,7 @@ namespace Demo.Domain.UseCase var existingGroup = ValidateGroupExistence(groupId); existingGroup.Name = newGroupName; - _repositoryGroupImpl.UpdateGroup(existingGroup); + _repositoryGroupImpl.UpdateGroupById(groupId,existingGroup); } } } \ No newline at end of file diff --git a/Demo/Domain/UseCase/UseCaseGeneratePresence.cs b/Demo/Domain/UseCase/UseCaseGeneratePresence.cs index 0660607..95d35bb 100644 --- a/Demo/Domain/UseCase/UseCaseGeneratePresence.cs +++ b/Demo/Domain/UseCase/UseCaseGeneratePresence.cs @@ -10,10 +10,10 @@ namespace Demo.Domain.UseCase { public class UseCaseGeneratePresence { - public readonly UserRepositoryImpl _userRepository; + public readonly IUserRepository _userRepository; public readonly IPresenceRepository _presenceRepository; - public UseCaseGeneratePresence(UserRepositoryImpl userRepository, IPresenceRepository presenceRepository) + public UseCaseGeneratePresence(IUserRepository userRepository, IPresenceRepository presenceRepository) { _userRepository = userRepository; _presenceRepository = presenceRepository; diff --git a/Demo/Domain/UseCase/UserUseCase.cs b/Demo/Domain/UseCase/UserUseCase.cs index 600c2ec..b93645e 100644 --- a/Demo/Domain/UseCase/UserUseCase.cs +++ b/Demo/Domain/UseCase/UserUseCase.cs @@ -1,4 +1,5 @@ using Demo.Data.Exceptions; +using Demo.Data.RemoteData.RemoteDataBase.DAO; using Demo.Data.Repository; using Demo.domain.Models; @@ -6,10 +7,10 @@ namespace Demo.Domain.UseCase { public class UserUseCase { - private readonly UserRepositoryImpl _repositoryUserImpl; - private readonly GroupRepositoryImpl _repositoryGroupImpl; + private readonly IUserRepository _repositoryUserImpl; + private readonly IGroupRepository _repositoryGroupImpl; - public UserUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl) + public UserUseCase(IUserRepository repositoryImpl, IGroupRepository repositoryGroupImpl) { _repositoryUserImpl = repositoryImpl; _repositoryGroupImpl = repositoryGroupImpl; @@ -39,7 +40,7 @@ namespace Demo.Domain.UseCase } // Приватный метод для валидации существования группы по ID - private GroupLocalEntity ValidateGroupExistence(int groupId) + private GroupDao ValidateGroupExistence(int groupId) { var group = _repositoryGroupImpl.GetAllGroups() .FirstOrDefault(g => g.Id == groupId); diff --git a/Demo/Migrations/20241025085326_InitialCreate.Designer.cs b/Demo/Migrations/20241025085326_InitialCreate.Designer.cs new file mode 100644 index 0000000..c3f3dd9 --- /dev/null +++ b/Demo/Migrations/20241025085326_InitialCreate.Designer.cs @@ -0,0 +1,123 @@ +// +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(RemoteDatabaseContext))] + [Migration("20241025085326_InitialCreate")] + partial class InitialCreate + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b => + { + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("IsAttedance") + .HasColumnType("boolean"); + + b.Property("LessonNumber") + .HasColumnType("integer"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("UserDaoUserId") + .HasColumnType("integer"); + + b.HasKey("UserId", "Date", "IsAttedance", "LessonNumber"); + + b.HasIndex("UserDaoUserId"); + + b.ToTable("PresenceDaos"); + }); + + modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); + + b.Property("FIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.HasKey("UserId"); + + 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("UserDaoUserId") + .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 + } + } +} diff --git a/Demo/Migrations/20241025085326_InitialCreate.cs b/Demo/Migrations/20241025085326_InitialCreate.cs new file mode 100644 index 0000000..643f15c --- /dev/null +++ b/Demo/Migrations/20241025085326_InitialCreate.cs @@ -0,0 +1,94 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Demo.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + UserId = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FIO = table.Column(type: "text", nullable: false), + GroupId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.UserId); + 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 + { + UserId = table.Column(type: "integer", nullable: false), + IsAttedance = table.Column(type: "boolean", nullable: false), + Date = table.Column(type: "date", nullable: false), + LessonNumber = table.Column(type: "integer", nullable: false), + UserDaoUserId = table.Column(type: "integer", nullable: false), + GroupId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PresenceDaos", x => new { x.UserId, x.Date, x.IsAttedance, x.LessonNumber }); + table.ForeignKey( + name: "FK_PresenceDaos_Users_UserDaoUserId", + column: x => x.UserDaoUserId, + principalTable: "Users", + principalColumn: "UserId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_PresenceDaos_UserDaoUserId", + table: "PresenceDaos", + column: "UserDaoUserId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_GroupId", + table: "Users", + column: "GroupId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PresenceDaos"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "Groups"); + } + } +} diff --git a/Demo/Migrations/RemoteDatabaseContextModelSnapshot.cs b/Demo/Migrations/RemoteDatabaseContextModelSnapshot.cs new file mode 100644 index 0000000..c4f2402 --- /dev/null +++ b/Demo/Migrations/RemoteDatabaseContextModelSnapshot.cs @@ -0,0 +1,120 @@ +// +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(RemoteDatabaseContext))] + partial class RemoteDatabaseContextModelSnapshot : 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.PresenceDao", b => + { + b.Property("UserId") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("IsAttedance") + .HasColumnType("boolean"); + + b.Property("LessonNumber") + .HasColumnType("integer"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.Property("UserDaoUserId") + .HasColumnType("integer"); + + b.HasKey("UserId", "Date", "IsAttedance", "LessonNumber"); + + b.HasIndex("UserDaoUserId"); + + b.ToTable("PresenceDaos"); + }); + + modelBuilder.Entity("Demo.Data.RemoteData.RemoteDataBase.DAO.UserDao", b => + { + b.Property("UserId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("UserId")); + + b.Property("FIO") + .IsRequired() + .HasColumnType("text"); + + b.Property("GroupId") + .HasColumnType("integer"); + + b.HasKey("UserId"); + + 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("UserDaoUserId") + .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 + } + } +} diff --git a/Demo/Program.cs b/Demo/Program.cs index 69f5544..df70b1d 100644 --- a/Demo/Program.cs +++ b/Demo/Program.cs @@ -5,26 +5,24 @@ using Demo.UI; using Microsoft.Extensions.DependencyInjection; // Создаем экземпляр репозиториев -GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl(); -UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl(); -PresenceRepositoryImpl presenceRepositoryImpl = new PresenceRepositoryImpl(); + IServiceCollection services = new ServiceCollection(); -services.AddDbContext(). - AddSingleton(); -services.AddDbContext(). - AddSingleton(); -services.AddDbContext(). - AddSingleton(); +services + .AddDbContext() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton(); -// Создаем UseCase для пользователей и групп -UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl); -GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl); -UseCaseGeneratePresence presenceUseCase = new UseCaseGeneratePresence(userRepositoryImpl, presenceRepositoryImpl); +var serviceProvider = services.BuildServiceProvider(); // Создаем пользовательский интерфейс -MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase, presenceUseCase); +MainMenuUI mainMenuUI = serviceProvider.GetService(); // Выводим главное меню mainMenuUI.DisplayMenu(); diff --git a/Demo/bin/Debug/net8.0/Demo.dll b/Demo/bin/Debug/net8.0/Demo.dll index 465d22c..5818eef 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 0c5e1ae..8a8331c 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 93cdd05..43060e1 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 15ab09f..38f5b33 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+0e15fc7d62cdcd2ecc8853e551035e8a3737aee9")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7d51508b530eabb76d3b4b1f318300167d3841e")] [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 c6d4a1c..67f8380 100644 --- a/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache +++ b/Demo/obj/Debug/net8.0/Demo.AssemblyInfoInputs.cache @@ -1 +1 @@ -4ece56c2162fd488c720e2f84da208a216fb7d2f8a4132ee7289842b3b121377 +493adb33b632bbecda0d79b7d44fbeac0c4f7b12d8b381a895bb0e6e1fed2bd3 diff --git a/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig b/Demo/obj/Debug/net8.0/Demo.GeneratedMSBuildEditorConfig.editorconfig index 38de3c6..aa29203 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\presence1\Demo\ +build_property.ProjectDir = C:\Users\adm\source\repos\presence1\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 6c842fe..ccfa742 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.CoreCompileInputs.cache b/Demo/obj/Debug/net8.0/Demo.csproj.CoreCompileInputs.cache index 42846e4..bc52d93 100644 --- a/Demo/obj/Debug/net8.0/Demo.csproj.CoreCompileInputs.cache +++ b/Demo/obj/Debug/net8.0/Demo.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -d802b7b93a990c8713727f8364fc47b1846b2dbf47bb30c6359a4f9f360292fb +30504035d845e5616feb21a777025026c55555e88052b83a111a265004d6549d diff --git a/Demo/obj/Debug/net8.0/Demo.dll b/Demo/obj/Debug/net8.0/Demo.dll index 465d22c..5818eef 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 8c75bc7..564ea07 100644 --- a/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache +++ b/Demo/obj/Debug/net8.0/Demo.genruntimeconfig.cache @@ -1 +1 @@ -bfad4a74ba74f7b6af7182a47faf922142f10d24ecb4676d49fb56abebdc3e22 +d5eb5cfbfe9d110c04bac2d0bacec315a054499e2bed6b39e50a2c77268548e7 diff --git a/Demo/obj/Debug/net8.0/Demo.pdb b/Demo/obj/Debug/net8.0/Demo.pdb index 93cdd05..43060e1 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 0c5e1ae..8a8331c 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 e9a31be..6dd5539 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 e9a31be..6dd5539 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.EntityFrameworkCore.targets b/Demo/obj/Demo.csproj.EntityFrameworkCore.targets new file mode 100644 index 0000000..7d6485d --- /dev/null +++ b/Demo/obj/Demo.csproj.EntityFrameworkCore.targets @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/obj/Demo.csproj.nuget.dgspec.json b/Demo/obj/Demo.csproj.nuget.dgspec.json index caf8fac..5e52fa0 100644 --- a/Demo/obj/Demo.csproj.nuget.dgspec.json +++ b/Demo/obj/Demo.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj": {} + "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj": {} }, "projects": { - "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj": { + "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj", + "projectUniqueName": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj", "projectName": "Demo", - "projectPath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj", + "projectPath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj", "packagesPath": "C:\\Users\\adm\\.nuget\\packages\\", - "outputPath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\obj\\", + "outputPath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ "C:\\Users\\adm\\AppData\\Roaming\\NuGet\\NuGet.Config", diff --git a/Demo/obj/project.nuget.cache b/Demo/obj/project.nuget.cache index 62dc760..e451d40 100644 --- a/Demo/obj/project.nuget.cache +++ b/Demo/obj/project.nuget.cache @@ -1,8 +1,8 @@ { "version": 2, - "dgSpecHash": "O3GkfNM2ZvQ=", + "dgSpecHash": "u1UuBtFmr6Y=", "success": true, - "projectFilePath": "C:\\Users\\adm\\Source\\Repos\\presence1\\Demo\\Demo.csproj", + "projectFilePath": "C:\\Users\\adm\\source\\repos\\presence1\\Demo\\Demo.csproj", "expectedPackageFiles": [ "C:\\Users\\adm\\.nuget\\packages\\humanizer.core\\2.14.1\\humanizer.core.2.14.1.nupkg.sha512", "C:\\Users\\adm\\.nuget\\packages\\microsoft.bcl.asyncinterfaces\\6.0.0\\microsoft.bcl.asyncinterfaces.6.0.0.nupkg.sha512",