a bunch of changes
This commit is contained in:
parent
36a123355e
commit
8ea8d00df0
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,24 +11,69 @@ using Posechaemost.Data.LocalData.Entity;
|
||||
|
||||
namespace Posechaemost.Data.Repository
|
||||
{
|
||||
public class GroupRepositoryImpl
|
||||
public class GroupRepositoryImpl: IGroupRepository
|
||||
{
|
||||
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
public GroupLocalEntity? UpdateGroup(String name)
|
||||
|
||||
public bool AddGroup(String name, String id)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.Name == name).FirstOrDefault();
|
||||
if (groupLocal == null) return null;
|
||||
GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault();
|
||||
// GroupLocalEntity? group = new GroupLocalEntity();
|
||||
groupLocal.Name = name;
|
||||
groupLocal.Id = int.Parse(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroup()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
|
||||
public GroupLocalEntity GetGroupById(int groupID)
|
||||
{
|
||||
GroupLocalEntity groupLocal = GetAllGroups()
|
||||
.Where(x => x.Id == groupID).FirstOrDefault();
|
||||
if (groupLocal == null) return null;
|
||||
return groupLocal;
|
||||
}
|
||||
|
||||
public GroupLocalEntity? AddGroup(String name, String id)
|
||||
public bool RemoveGroupById(int groupID)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault();
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.Id == groupID).FirstOrDefault();
|
||||
if (groupLocal == null) return false;
|
||||
|
||||
return GetAllGroups().Remove(groupLocal);
|
||||
}
|
||||
|
||||
public bool UpdateGroupById(int groupID, String name)
|
||||
{
|
||||
GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
.Where(x => x.Id == groupID).FirstOrDefault();
|
||||
if (groupLocal == null) return false;
|
||||
groupLocal.Name = name;
|
||||
groupLocal.Id = int.Parse(id);
|
||||
return groupLocal;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// {
|
||||
// public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
|
||||
// public GroupLocalEntity? UpdateGroup(String name)
|
||||
// {
|
||||
// GroupLocalEntity? groupLocal = GetAllGroups()
|
||||
// .Where(x => x.Name == name).FirstOrDefault();
|
||||
// if (groupLocal == null) return null;
|
||||
// groupLocal.Name = name;
|
||||
// return groupLocal;
|
||||
// }
|
||||
|
||||
// public GroupLocalEntity? AddGroup(String name, String id)
|
||||
// {
|
||||
// GroupLocalEntity? groupLocal = GetAllGroups().FirstOrDefault();
|
||||
// // GroupLocalEntity? group = new GroupLocalEntity(name, id);
|
||||
// groupLocal.Name = name;
|
||||
// groupLocal.Id = int.Parse(id);
|
||||
// return groupLocal;
|
||||
// }
|
||||
// }
|
17
Data/Repository/IGroupRepository.cs
Normal file
17
Data/Repository/IGroupRepository.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Posechaemost.Data.LocalData.Entity;
|
||||
|
||||
namespace Posechaemost.Data.Repository {
|
||||
public interface IGroupRepository
|
||||
{
|
||||
List<GroupLocalEntity> GetAllGroup();
|
||||
bool RemoveGroupById(int groupID);
|
||||
bool UpdateGroupById(int groupID, String name);
|
||||
GroupLocalEntity GetGroupById(int groupID);
|
||||
bool AddGroup(String name, String id);
|
||||
}
|
||||
}
|
17
Data/Repository/IUserRepository.cs
Normal file
17
Data/Repository/IUserRepository.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Posechaemost.Data.LocalData.Entity;
|
||||
|
||||
namespace Posechaemost.Data.Repository {
|
||||
public interface IUserRepository
|
||||
{
|
||||
List<UserLocalEntity> GetAllUser();
|
||||
bool RemoveUserByGuid(Guid userGuid);
|
||||
UserLocalEntity? GetUserByGuid(Guid userGuid);
|
||||
UserLocalEntity? UpdateUser(UserLocalEntity userUpdateLocalEnity);
|
||||
UserLocalEntity? UpdateUserByGuid(Guid userGuid);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Posechaemost.Data.LocalData;
|
||||
@ -9,12 +8,18 @@ using Posechaemost.Data.LocalData.Entity;
|
||||
|
||||
namespace Posechaemost.Data.Repository
|
||||
{
|
||||
public class UserRepositoryImpl
|
||||
public class UserRepositoryImpl: IUserRepository
|
||||
{
|
||||
public UserRepositoryImpl() {
|
||||
|
||||
GetAllUsers = LocalStaticData.users;
|
||||
}
|
||||
|
||||
public List<UserLocalEntity> GetAllUser()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<UserLocalEntity> GetAllUsers
|
||||
{ get; set; }
|
||||
|
||||
|
@ -21,14 +21,10 @@ namespace Posechaemost.Domain.UseCase
|
||||
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
|
||||
.Select(it => new Group { Id = it.Id, Name = it.Name}).ToList();
|
||||
|
||||
public Group UpdateGroupName(String name, String name1) {
|
||||
GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroup(name);
|
||||
if (result == null) throw new Exception("");
|
||||
Group? group = GetAllGroups().FirstOrDefault(it => it.Name == result.Name);
|
||||
if (group == null) throw new Exception("");
|
||||
return new Group {Id = group.Id, Name = name1};
|
||||
public bool UpdateGroupName(String id, String name1) {
|
||||
return _repositoryGroupImpl.UpdateGroupById(int.Parse(id), name1);
|
||||
}
|
||||
public GroupLocalEntity AddGroup(String name, String id)
|
||||
public bool AddGroup(String name, String id)
|
||||
{
|
||||
return _repositoryGroupImpl.AddGroup(name, id);
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ namespace Posechaemost.Domain.UseCase
|
||||
{
|
||||
public class UserUseCase
|
||||
{
|
||||
private UserRepositoryImpl _repositoryUserImpl;
|
||||
private GroupRepositoryImpl _repositoryGroupImpl;
|
||||
|
||||
private readonly UserRepositoryImpl _repositoryUserImpl;
|
||||
private readonly IGroupRepository _repositoryGroupImpl;
|
||||
|
||||
public UserUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl)
|
||||
{
|
||||
@ -20,10 +21,10 @@ namespace Posechaemost.Domain.UseCase
|
||||
_repositoryGroupImpl = repositoryGroupImpl;
|
||||
}
|
||||
|
||||
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
|
||||
private List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroup()
|
||||
.Select(it => new Group { Id = it.Id, Name = it.Name}).ToList();
|
||||
public List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers
|
||||
.Join(_repositoryGroupImpl.GetAllGroups(),
|
||||
.Join(_repositoryGroupImpl.GetAllGroup(),
|
||||
user => user.GroupID,
|
||||
group => group.Id,
|
||||
(user, group) =>
|
||||
|
@ -7,4 +7,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
13
Program.cs
13
Program.cs
@ -1,10 +1,19 @@
|
||||
using Posechaemost.Data.Repository;
|
||||
using Posechaemost.Domain.UseCase;
|
||||
using Posechaemost.UI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
|
||||
services
|
||||
.AddSingleton<IGroupRepository, GroupRepositoryImpl>()
|
||||
.AddSingleton<UserUseCase>();
|
||||
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
|
||||
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
|
||||
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);
|
||||
UserUseCase userUseCase = serviceProvider.GetService<UserUseCase>();
|
||||
GroupUseCase groupUseCase = new GroupUseCase(groupRepositoryImpl);
|
||||
|
||||
MainMenuUI mainMenuUI = new MainMenuUI(userUseCase, groupUseCase);
|
@ -13,10 +13,10 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Posechaemost")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1305f40f241ce752d3c0a7ec5341b1eafac497d8")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+36a123355e04422229f0afaff5d2c6d503a8419e")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Posechaemost")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Posechaemost")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
7a59f60438c72dd05578b09f953c9ba9d3343469014f076958deeba098123188
|
||||
c78a5718d92cc56f307f18b87610c16cd6bd4adb899ce2e54039bee5d3d6ceb2
|
||||
|
Binary file not shown.
BIN
obj/Debug/net8.0/Posechaemost.csproj.AssemblyReference.cache
Normal file
BIN
obj/Debug/net8.0/Posechaemost.csproj.AssemblyReference.cache
Normal file
Binary file not shown.
@ -42,6 +42,12 @@
|
||||
"frameworks": {
|
||||
"net8.0": {
|
||||
"targetAlias": "net8.0",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection": {
|
||||
"target": "Package",
|
||||
"version": "[8.0.1, )"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
|
@ -1,11 +1,114 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net8.0": {}
|
||||
"net8.0": {
|
||||
"Microsoft.Extensions.DependencyInjection/8.0.1": {
|
||||
"type": "package",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2"
|
||||
},
|
||||
"compile": {
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"buildTransitive/net6.0/_._": {}
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/8.0.2": {
|
||||
"type": "package",
|
||||
"compile": {
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {
|
||||
"related": ".xml"
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"buildTransitive/net6.0/_._": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Microsoft.Extensions.DependencyInjection/8.0.1": {
|
||||
"sha512": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==",
|
||||
"type": "package",
|
||||
"path": "microsoft.extensions.dependencyinjection/8.0.1",
|
||||
"files": [
|
||||
".nupkg.metadata",
|
||||
".signature.p7s",
|
||||
"Icon.png",
|
||||
"LICENSE.TXT",
|
||||
"PACKAGE.md",
|
||||
"THIRD-PARTY-NOTICES.TXT",
|
||||
"buildTransitive/net461/Microsoft.Extensions.DependencyInjection.targets",
|
||||
"buildTransitive/net462/_._",
|
||||
"buildTransitive/net6.0/_._",
|
||||
"buildTransitive/netcoreapp2.0/Microsoft.Extensions.DependencyInjection.targets",
|
||||
"lib/net462/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/net462/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"lib/net6.0/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/net6.0/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"lib/net7.0/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/net7.0/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.dll",
|
||||
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.xml",
|
||||
"microsoft.extensions.dependencyinjection.8.0.1.nupkg.sha512",
|
||||
"microsoft.extensions.dependencyinjection.nuspec",
|
||||
"useSharedDesignerContext.txt"
|
||||
]
|
||||
},
|
||||
"Microsoft.Extensions.DependencyInjection.Abstractions/8.0.2": {
|
||||
"sha512": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==",
|
||||
"type": "package",
|
||||
"path": "microsoft.extensions.dependencyinjection.abstractions/8.0.2",
|
||||
"files": [
|
||||
".nupkg.metadata",
|
||||
".signature.p7s",
|
||||
"Icon.png",
|
||||
"LICENSE.TXT",
|
||||
"PACKAGE.md",
|
||||
"THIRD-PARTY-NOTICES.TXT",
|
||||
"buildTransitive/net461/Microsoft.Extensions.DependencyInjection.Abstractions.targets",
|
||||
"buildTransitive/net462/_._",
|
||||
"buildTransitive/net6.0/_._",
|
||||
"buildTransitive/netcoreapp2.0/Microsoft.Extensions.DependencyInjection.Abstractions.targets",
|
||||
"lib/net462/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/net462/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"lib/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/net6.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"lib/net7.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/net7.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.Abstractions.dll",
|
||||
"lib/netstandard2.1/Microsoft.Extensions.DependencyInjection.Abstractions.xml",
|
||||
"microsoft.extensions.dependencyinjection.abstractions.8.0.2.nupkg.sha512",
|
||||
"microsoft.extensions.dependencyinjection.abstractions.nuspec",
|
||||
"useSharedDesignerContext.txt"
|
||||
]
|
||||
}
|
||||
},
|
||||
"libraries": {},
|
||||
"projectFileDependencyGroups": {
|
||||
"net8.0": []
|
||||
"net8.0": [
|
||||
"Microsoft.Extensions.DependencyInjection >= 8.0.1"
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"/home/gara/.nuget/packages/": {}
|
||||
@ -48,6 +151,12 @@
|
||||
"frameworks": {
|
||||
"net8.0": {
|
||||
"targetAlias": "net8.0",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.DependencyInjection": {
|
||||
"target": "Package",
|
||||
"version": "[8.0.1, )"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
|
@ -1,8 +1,11 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "3K0+oSHYQvE=",
|
||||
"dgSpecHash": "JxuWkwCqUKY=",
|
||||
"success": true,
|
||||
"projectFilePath": "/home/gara/csharp/Posechaemost/Posechaemost.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"expectedPackageFiles": [
|
||||
"/home/gara/.nuget/packages/microsoft.extensions.dependencyinjection/8.0.1/microsoft.extensions.dependencyinjection.8.0.1.nupkg.sha512",
|
||||
"/home/gara/.nuget/packages/microsoft.extensions.dependencyinjection.abstractions/8.0.2/microsoft.extensions.dependencyinjection.abstractions.8.0.2.nupkg.sha512"
|
||||
],
|
||||
"logs": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user