diff --git a/Zurnal/Date/Repository/GroupRepositoryImpl.cs b/Zurnal/Date/Repository/GroupRepositoryImpl.cs index 1542f87..96dac90 100644 --- a/Zurnal/Date/Repository/GroupRepositoryImpl.cs +++ b/Zurnal/Date/Repository/GroupRepositoryImpl.cs @@ -1,83 +1,117 @@ -using Zurnal.domain.Models; -using System.Diagnostics; +using System.Diagnostics; +using System.Linq; +using System.Collections.Generic; using Zurnal.Date.LocalDate; using Zurnal.Date.Repository; +using Zurnal.RemaDateBase.DateDao; +using System.Text.RegularExpressions; namespace Zurnal.Data.Repository { [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] public class GroupRepositoryImpl : IGroupRepository { - public List GetAllGroups() => LocalStaticData.groups; + public List AllGroup => GroupDao.Name.ToList(); - public void AddGroup(GroupLocalEntity newGroup) + public IEnumerable GetAllGroups() { - LocalStaticData.groups.Add(newGroup); + return GroupDao.Name; } - public void UpdateGroupName(int groupId, string newName) -{ - var group = LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId); - if (group != null) - { - group.Name = newName; - } -} - - - public GroupLocalEntity GetGroupById(int groupId) + public void AddGroup(GroupDao group) { - return LocalStaticData.groups.FirstOrDefault(g => g.Id == groupId); + if (group == null) + { + throw new ArgumentNullException(nameof(group)); + } + GroupDao.Name.Add(group); + } + + public void UpdateGroupName(int groupId, string name) + { + var group = GroupDao.Name.FirstOrDefault(g => g.Id == groupId); + if (group != null) + { + group.Name = name; + } + } + + public GroupDao GetGroupById(int id) + { + return GroupDao.groups.FirstOrDefault(g => g.Id == id); } private static string GetDebuggerDisplay() { - return $"GroupRepository with {LocalStaticData.groups.Count} groups"; + return $"GroupRepository with {GroupDao.groups.Count} groups"; } - internal void AddGroup(Group group) + public bool RemoveGroupById(int groupId) { - throw new NotImplementedException(); + var group = GroupDao.groups.FirstOrDefault(g => g.Id == groupId); + if (group != null) + { + GroupDao.groups.Remove(group); + return true; + } + return false; } - public List AllGroup => throw new NotImplementedException(); - - public bool RemoveGroupById(int groupID) + public IEnumerable AllGroups() { - throw new NotImplementedException(); + return GroupDao.groups.Select(g => new GroupDao { GroupName = g.Name, Id = g.Id }); } - public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) + public bool UpdateGroupById(int groupId, GroupDao updatedGroup) { - throw new NotImplementedException(); + var group = GroupDao.groups.FirstOrDefault(g => g.Id == groupId); + if (group != null) + { + group.Name = updatedGroup.GroupName; + return true; + } + return false; } - bool IGroupRepository.AddGroup(GroupLocalEntity newGroup) + public void UpdateGroup(GroupDao group) { - throw new NotImplementedException(); - } - - public void AddGroupFromRegex(System.Text.RegularExpressions.Group group) - { - throw new NotImplementedException(); - } - - System.Text.RegularExpressions.Group IGroupRepository.GetGroupById(int id) - { - throw new NotImplementedException(); - } - - IEnumerable IGroupRepository.GetAllGroups() - { - throw new NotImplementedException(); - } - - public void UpdateGroup(System.Text.RegularExpressions.Group group) - { - throw new NotImplementedException(); + var existingGroup = GroupDao.groups.FirstOrDefault(g => g.Id == group.Id); + if (existingGroup != null) + { + existingGroup.Name = group.GroupName; + } } public void DeleteGroup(int id) + { + var group = GroupDao.groups.FirstOrDefault(g => g.Id == id); + if (group != null) + { + GroupDao.groups.Remove(group); + } + } + + public bool AddGroup(GroupDao newGroup) + { + if (newGroup == null) + { + throw new ArgumentNullException(nameof(newGroup)); + } + GroupDao.groups.Add(newGroup); + return true; + } + + public void AddGroupFromRegex(Group group) + { + throw new NotImplementedException(); + } + + IEnumerable IGroupRepository.AllGroups() + { + throw new NotImplementedException(); + } + + public void AddGroupFromRegex(Group group) { throw new NotImplementedException(); } diff --git a/Zurnal/RemaDateBase/DateDao/GroupDao.cs b/Zurnal/RemaDateBase/DateDao/GroupDao.cs index cb3967d..a365118 100644 --- a/Zurnal/RemaDateBase/DateDao/GroupDao.cs +++ b/Zurnal/RemaDateBase/DateDao/GroupDao.cs @@ -2,7 +2,9 @@ { public class GroupDao { - public int Id { get; set; } + internal static IEnumerable Name; + + public int Id { get; set; } public required string GroupName { get; set; } public IEnumerable Users { get; set; } } diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs index d39ad86..c589e4d 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs +++ b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs @@ -13,7 +13,7 @@ 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+f21c9eea749518815b6e31d670ea46d546ea1377")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d72fa803793c5d114c3eabb8fe2de04cd2042db1")] [assembly: System.Reflection.AssemblyProductAttribute("Zurnal")] [assembly: System.Reflection.AssemblyTitleAttribute("Zurnal")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache index 9b90922..1282f10 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache +++ b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache @@ -1 +1 @@ -1914265bd793edbfbb26abfea7e619e59449b0884ab15982620c0f061967d422 +7af827faec1f5dd576cc86e70a9c41ec992b431c5545340778b3dec093fd4ac1 diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache b/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache index b4fc97a..5ea1952 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache +++ b/Zurnal/obj/Debug/net8.0/Zurnal.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -6c6720db556a4418cad2bec16d4d434fb3bb5d14252123bfac524503f5ff6976 +284ebdeb3fab184734b12e3b8ba05c6bb9ebc0011e646a87edcca3ea143abd87 diff --git a/Zurnal/tempCodeRunnerFile.cs b/Zurnal/tempCodeRunnerFile.cs new file mode 100644 index 0000000..136305e --- /dev/null +++ b/Zurnal/tempCodeRunnerFile.cs @@ -0,0 +1,9 @@ +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