From 6cd68fd8f848f82dab9dfb3c0fa57e7014aa5697 Mon Sep 17 00:00:00 2001 From: Userok Date: Thu, 7 Nov 2024 14:31:00 +0300 Subject: [PATCH] --- .vs/slnx.sqlite | Bin 598016 -> 598016 bytes Zurnal/Date/Repository/IGroupRepository.cs | 5 +- Zurnal/Date/Repository/SQLNado.cs | 52 ++++++++++++++++++ Zurnal/Domain/Recvara/Recvarer.cs | 7 +++ Zurnal/Domain/Respy/GroupRespy.cs | 4 ++ Zurnal/Domain/UseCase/GroupUseCase.cs | 16 ++++++ Zurnal/Program.cs | 23 +++++--- Zurnal/RemaDateBase/RemoutDateBase.cs | 2 - Zurnal/UI/GroupConsol.cs | 33 +++++++++++ .../obj/Debug/net8.0/Zurnal.AssemblyInfo.cs | 2 +- .../net8.0/Zurnal.AssemblyInfoInputs.cache | 2 +- 11 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 Zurnal/Date/Repository/SQLNado.cs create mode 100644 Zurnal/Domain/Recvara/Recvarer.cs create mode 100644 Zurnal/Domain/Respy/GroupRespy.cs create mode 100644 Zurnal/UI/GroupConsol.cs diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index d19a5ec01e787cd1571b61754045fbe082e0df94..3f5355f57b16ce5eda3ed344788036781dfdf3fa 100644 GIT binary patch delta 83 zcmZoTpwe(aWr8$g{6raN#`uj1|D<`1O|48V`7baQFgUlWPj0lA-uz#Zm9e>7w!K@H d5r~<9m>Gy!fS47C*?^cGh&i@*%W{@70RW7M8jk<~ delta 83 zcmZoTpwe(aWr8$g+(a2?#<-0M|D<`1EUZk-_%ARPFgUlWPj0lA-uz#Zm9e>7w!K@H d5r~<9m>Gy!fS47C*?^cGh&i@*%W{@70RW4K8jAn` diff --git a/Zurnal/Date/Repository/IGroupRepository.cs b/Zurnal/Date/Repository/IGroupRepository.cs index 47392d9..0de9391 100644 --- a/Zurnal/Date/Repository/IGroupRepository.cs +++ b/Zurnal/Date/Repository/IGroupRepository.cs @@ -1,4 +1,5 @@ -using Zurnal.RemaDateBase.DateDao; +using Zurnal.domain.Models; +using Zurnal.RemaDateBase.DateDao; internal interface IGroupRepository { @@ -8,7 +9,7 @@ internal interface IGroupRepository { return AllGroup.Select(g => new GroupDao { GroupName = g.GroupName, Id = g.Id }); } - +List GetAllGroup(); public bool RemoveGroupById(int groupId) { var group = AllGroup.FirstOrDefault(g => g.Id == groupId); diff --git a/Zurnal/Date/Repository/SQLNado.cs b/Zurnal/Date/Repository/SQLNado.cs new file mode 100644 index 0000000..e013952 --- /dev/null +++ b/Zurnal/Date/Repository/SQLNado.cs @@ -0,0 +1,52 @@ +using Zurnal.Date.LocalDate; +using Zurnal.domain.Models; +using Zurnal.RemaDateBase.DateDao; + +namespace Data.Repository +{ + public class SQLGroupRepositoryImpl:IGroupRepository + { + private readonly RemoteDateBaseContext _remoteDataBaseContext; + + public SQLGroupRepositoryImpl(RemoteDateBaseContext remoteDataBaseContext) { + _remoteDataBaseContext = remoteDataBaseContext; + } + + public List AllGroup => throw new NotImplementedException(); + + public bool AddGroup(GroupLocalEntity newGroup) + { + GroupDao groupDao = new GroupDao { GroupName = newGroup.Name }; + var result = _remoteDataBaseContext.Group.Add(groupDao); + if (result != null) { + _remoteDataBaseContext.SaveChanges(); + return true; } + return false; + } + + public List GetAllGroup() + { + return _remoteDataBaseContext.Group.Select(group => new GroupLocalEntity{ + Id = group.Id, + Name = group.GroupName} + ).ToList(); + } + + public List GetAllGroups() => LocalStaticData.groups; + + public GroupLocalEntity GetGroupById(int groupID) + { + throw new NotImplementedException(); + } + + public bool RemoveGroupById(int groupID) + { + throw new NotImplementedException(); + } + + public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Zurnal/Domain/Recvara/Recvarer.cs b/Zurnal/Domain/Recvara/Recvarer.cs new file mode 100644 index 0000000..628c914 --- /dev/null +++ b/Zurnal/Domain/Recvara/Recvarer.cs @@ -0,0 +1,7 @@ +namespace domain.Models.RequestModels +{ + public class GroupAddRequest + { + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Zurnal/Domain/Respy/GroupRespy.cs b/Zurnal/Domain/Respy/GroupRespy.cs new file mode 100644 index 0000000..da5ec1e --- /dev/null +++ b/Zurnal/Domain/Respy/GroupRespy.cs @@ -0,0 +1,4 @@ +public class GroupResponse{ + public int Id {get; set;} + public string Name {get; set;} +} \ No newline at end of file diff --git a/Zurnal/Domain/UseCase/GroupUseCase.cs b/Zurnal/Domain/UseCase/GroupUseCase.cs index 4882494..640b95d 100644 --- a/Zurnal/Domain/UseCase/GroupUseCase.cs +++ b/Zurnal/Domain/UseCase/GroupUseCase.cs @@ -1,9 +1,11 @@ using Zurnal.Data.Repository; +using Zurnal.domain.Models; using Zurnal.RemaDateBase.DateDao; namespace Zurnal.Domain.UseCase { public class GroupUseCase : IGroupRepository { + private readonly IGroupRepository _repository; private List _groups = new List(); public List AllGroup => _groups; private UserRepositoryImpl _repositoryUserImpl; @@ -59,5 +61,19 @@ namespace Zurnal.Domain.UseCase { return _groups.FirstOrDefault(g => g.Id == id); } + + public List getAllGroup(){ + return _repository.GetAllGroup().Select(group => + new GroupResponse { + Id = group.Id, + Name = group.Name + } + ).ToList(); } + + public List GetAllGroup() + { + throw new NotImplementedException(); + } + } } \ No newline at end of file diff --git a/Zurnal/Program.cs b/Zurnal/Program.cs index fca8221..915bca2 100644 --- a/Zurnal/Program.cs +++ b/Zurnal/Program.cs @@ -1,9 +1,18 @@ -using Zurnal.UI; -using Zurnal.Data.Repository; -using Zurnal.Domain.UseCase; +using Zurnal.Domain.UseCase; +using Microsoft.Extensions.DependencyInjection; +using UI; +using Data.Repository; -GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl(); -UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl(); -UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl); +IServiceCollection services = new ServiceCollection(); -MainMenuUI mainMenuUI = new MainMenuUI(userUseCase); \ No newline at end of file +services + .AddDbContext() + .AddSingleton() + .AddSingleton() + .AddSingleton(); + +var serviceProvider = services.BuildServiceProvider(); + +GroupConsol groupUI = serviceProvider.GetService(); + +groupUI.AddGroup(); \ No newline at end of file diff --git a/Zurnal/RemaDateBase/RemoutDateBase.cs b/Zurnal/RemaDateBase/RemoutDateBase.cs index e8b70d1..cc3141f 100644 --- a/Zurnal/RemaDateBase/RemoutDateBase.cs +++ b/Zurnal/RemaDateBase/RemoutDateBase.cs @@ -3,8 +3,6 @@ using Zurnal.RemaDateBase.DateDao; public class RemoteDateBaseContext : DbContext { - public RemoteDateBaseContext() { } - public DbSet Group { get; set; } public DbSet User { get; set; } public DbSet Presence { get; set; } diff --git a/Zurnal/UI/GroupConsol.cs b/Zurnal/UI/GroupConsol.cs new file mode 100644 index 0000000..31edb62 --- /dev/null +++ b/Zurnal/UI/GroupConsol.cs @@ -0,0 +1,33 @@ +using domain; +using domain.Models.RequestModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Zurnal.Domain.UseCase; +using Zurnal.RemaDateBase.DateDao; + +namespace UI +{ + public class GroupConsol + { + private readonly GroupUseCase _groupUseCase; + public GroupConsol(GroupUseCase groupUseCase) { + _groupUseCase = groupUseCase; + } + + public void AddGroup() { + Console.WriteLine("Введите название группы: "); + string groupName = Console.ReadLine(); + + if (string.IsNullOrWhiteSpace(groupName)) { + Console.WriteLine("Название группы не может быть пустым. Пожалуйста, введите корректное название."); + return; + } + GroupDao groupDao = new GroupDao { GroupName = groupName }; + _groupUseCase.AddGroup(groupDao); + } + } + +} \ No newline at end of file diff --git a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfo.cs index adc3f65..daad15f 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+979f0a84e8934a72efb3311a281d819c04f351b5")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cefc9b3a85c12cb82d7e543ab8d2eb025849b9ec")] [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 d7ac961..806d11a 100644 --- a/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache +++ b/Zurnal/obj/Debug/net8.0/Zurnal.AssemblyInfoInputs.cache @@ -1 +1 @@ -81b7b72033be0fe61e2a2ba2abf77030b6175ed4211ce31436b98277e897b53f +e861d9be05b9445b3ebef44d26117a8c4b30fb141208d42302beba8abc1372c1