This commit is contained in:
adm 2024-10-14 14:19:48 +03:00
parent 720907a3d0
commit 185d423698
4 changed files with 56 additions and 4 deletions

View File

@ -18,7 +18,7 @@ namespace Demo.Data.LocalData
new GroupLocalEntity{ Id = 3, Name = "ИП1-23" }, new GroupLocalEntity{ Id = 3, Name = "ИП1-23" },
}; };
public static IEnumerable<UserLocalEnity> users => new List<UserLocalEnity> public static List<UserLocalEnity> users => new List<UserLocalEnity>
{ {
new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio", GroupID = 1 }, new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio", GroupID = 1 },
new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio1", GroupID = 2 }, new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio1", GroupID = 2 },

View File

@ -1,4 +1,6 @@
using System; using Demo.Data.LocalData;
using Demo.domain.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -6,7 +8,38 @@ using System.Threading.Tasks;
namespace Demo.Data.Repository namespace Demo.Data.Repository
{ {
internal class UserRepositoryImpl public class UserRepositoryImpl
{ {
public IEnumerable<UserLocalEnity> GetAllUsers() => LocalStaticData.users;
public bool RemoveUserByGuid(Guid userGuid)
{
UserLocalEnity? userLocal = LocalStaticData
.users
.Where(x => x.Guid == userGuid).FirstOrDefault();
if (userLocal == null) return false;
return LocalStaticData.users.Remove(userLocal);
}
public UserLocalEnity? GetUserByGuid(Guid userGuid) {
UserLocalEnity? userLocal = LocalStaticData
.users
.Where(x => x.Guid == userGuid).FirstOrDefault();
if (userLocal == null) return null;
return userLocal;
}
public UserLocalEnity? UpdateUserByGuid(UserLocalEnity userUpdateLocalEnity) {
UserLocalEnity? userLocal = LocalStaticData
.users
.Where(x => x.Guid == userUpdateLocalEnity.Guid).FirstOrDefault();
if (userLocal == null) return null;
userLocal.FIO = userUpdateLocalEnity.FIO;
userLocal.GroupID = userUpdateLocalEnity.GroupID;
return userLocal;
}
} }
} }

View File

@ -9,7 +9,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="Data\RemoteData\" /> <Folder Include="Data\RemoteData\" />
<Folder Include="Domain\UseCase\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,20 @@
using Demo.Data.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo.Domain.UseCase
{
public class UserUseCase
{
private UserRepositoryImpl _repositoryImpl;
public UserUseCase(UserRepositoryImpl repositoryImpl)
{
_repositoryImpl = repositoryImpl;
}
}
}