diff --git a/Demo/Data/LocalData/LocalStaticData.cs b/Demo/Data/LocalData/LocalStaticData.cs index d82d881..aebb784 100644 --- a/Demo/Data/LocalData/LocalStaticData.cs +++ b/Demo/Data/LocalData/LocalStaticData.cs @@ -18,7 +18,7 @@ namespace Demo.Data.LocalData new GroupLocalEntity{ Id = 3, Name = "ИП1-23" }, }; - public static IEnumerable users => new List + public static List users => new List { new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio", GroupID = 1 }, new UserLocalEnity{Guid=Guid.NewGuid(), FIO = "RandomFio1", GroupID = 2 }, diff --git a/Demo/Data/Repository/UserRepositoryImpl.cs b/Demo/Data/Repository/UserRepositoryImpl.cs index f4cbbc6..9d802fd 100644 --- a/Demo/Data/Repository/UserRepositoryImpl.cs +++ b/Demo/Data/Repository/UserRepositoryImpl.cs @@ -1,4 +1,6 @@ -using System; +using Demo.Data.LocalData; +using Demo.domain.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +8,38 @@ using System.Threading.Tasks; namespace Demo.Data.Repository { - internal class UserRepositoryImpl + public class UserRepositoryImpl { + public IEnumerable 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; + + } } } diff --git a/Demo/Demo.csproj b/Demo/Demo.csproj index e338845..1ea2759 100644 --- a/Demo/Demo.csproj +++ b/Demo/Demo.csproj @@ -9,7 +9,6 @@ - diff --git a/Demo/Domain/UseCase/UserUseCase.cs b/Demo/Domain/UseCase/UserUseCase.cs new file mode 100644 index 0000000..b98a077 --- /dev/null +++ b/Demo/Domain/UseCase/UserUseCase.cs @@ -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; + } + + } +}