diff --git a/Zurnal/Date/Repository/GroupRepositoryImpl.cs b/Zurnal/Date/Repository/GroupRepositoryImpl.cs index 8bdef94..e2e6dc6 100644 --- a/Zurnal/Date/Repository/GroupRepositoryImpl.cs +++ b/Zurnal/Date/Repository/GroupRepositoryImpl.cs @@ -72,9 +72,9 @@ public bool UpdateGroupById(int groupId, GroupDao updatedGroup) GroupDao.Name.Remove(group); } } - public void UpdateGroup(GroupDao group) - { - throw new NotImplementedException(); - } + public GroupDao FindGroupById(int groupId) + { + return AllGroup.FirstOrDefault(g => g.Id == groupId); } +} } \ No newline at end of file diff --git a/Zurnal/Date/Repository/IGroupRepository.cs b/Zurnal/Date/Repository/IGroupRepository.cs index e4dd88b..47392d9 100644 --- a/Zurnal/Date/Repository/IGroupRepository.cs +++ b/Zurnal/Date/Repository/IGroupRepository.cs @@ -62,4 +62,18 @@ internal interface IGroupRepository group.GroupName = name; } } + public bool UpdateUser(Guid userGuid, UserDao updatedUser) + { + if (updatedUser == null) throw new ArgumentNullException(nameof(updatedUser)); + + var user = AllGroup.SelectMany(g => g.Users).FirstOrDefault(u => u.UserGuid == userGuid); + if (user != null) + { + user.FIO = updatedUser.FIO; + user.GroupID = updatedUser.GroupID; + user.Group = updatedUser.Group; + return true; + } + return false; + } } \ No newline at end of file diff --git a/Zurnal/Domain/UseCase/GroupUseCase.cs b/Zurnal/Domain/UseCase/GroupUseCase.cs index dda8c54..4882494 100644 --- a/Zurnal/Domain/UseCase/GroupUseCase.cs +++ b/Zurnal/Domain/UseCase/GroupUseCase.cs @@ -37,7 +37,7 @@ namespace Zurnal.Domain.UseCase public bool RemoveGroupById(int groupID) { - var group = _repositoryGroupImpl.GetGroupById(groupID); + var group = _repositoryGroupImpl.FindGroupById(groupID); if (group == null) { return false; diff --git a/Zurnal/Domain/UseCase/UserUseCase.cs b/Zurnal/Domain/UseCase/UserUseCase.cs index d7baa96..5f8d644 100644 --- a/Zurnal/Domain/UseCase/UserUseCase.cs +++ b/Zurnal/Domain/UseCase/UserUseCase.cs @@ -30,16 +30,6 @@ namespace Zurnal.Domain.UseCase return _repositoryUserImpl.RemoveUserByGuid(userGuid); } - public UserDao UpdateUser(UserDao user, int groupId) -{ - UserLocalEntity userLocalEntity = new UserLocalEntity { FIO = user.FIO, GroupID = groupId, Guid = user.UserGuid }; - UserLocalEntity? result = _repositoryUserImpl.UpdateUser(userLocalEntity); - if (result == null) throw new Exception("Пользователь не обновлен."); - GroupDao? group = GetAllGroups().FirstOrDefault(it => it.Id == result.GroupID); - if (group == null) throw new Exception("Група не нфйдуна."); - return new UserDao { FIO = user.FIO, UserGuid = user.UserGuid, Group = group, GroupID = group.Id }; -} - public IEnumerable GetAllGroups() { return RepositoryGroupImpl.AllGroup; @@ -66,11 +56,6 @@ namespace Zurnal.Domain.UseCase public List AllGroup => RepositoryGroupImpl.AllGroup.ToList(); List IGroupRepository.AllGroup => throw new NotImplementedException(); - - IEnumerable IGroupRepository.AllGroups() - { - return (IEnumerable)((IGroupRepository)_repositoryUserImpl).GetAllGroups(); - } internal class UserLocalEntity { public string FIO { get; set; } diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs index e900170..301b687 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs +++ b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs @@ -13,10 +13,10 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Zurnal")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+34ff2ea057283cd78eb7b49bd26432b8fed15732")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e86bec8a7f833b7d641968f35cc2ebce20da3dc8")] [assembly: System.Reflection.AssemblyProductAttribute("Zurnal")] [assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] -// Создано классом WriteCodeFragment MSBuild. +// Generated by the MSBuild WriteCodeFragment class. diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache index 59afe9c..1a05c09 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache +++ b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache @@ -1 +1 @@ -0df9278f60a66dc8e6fa4dcbb3c724fa603d832d40511f5c21919f1d6dd33202 +91af4bd6b85cc028ddbbf62d14f2f440aae593b748896e98c6bba89005927b76 diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache b/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache index 5ea1952..c29fa1a 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache +++ b/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -284ebdeb3fab184734b12e3b8ba05c6bb9ebc0011e646a87edcca3ea143abd87 +132477173c8f0b9bd98b70bc6d28240502a0a14c41a11367b550c5913679e10c diff --git a/Zurnal/tempCodeRunnerFile.cs b/Zurnal/tempCodeRunnerFile.cs deleted file mode 100644 index 136305e..0000000 --- a/Zurnal/tempCodeRunnerFile.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Zurnal.UI; -using Zurnal.Data.Repository; -using Zurnal.Domain.UseCase; - -GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl(); -UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl(); -UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl); - -MainMenuUI mainMenuUI = new MainMenuUI(userUseCase); \ No newline at end of file