diff --git a/Data/Repository/GroupRepositoryImpl.cs b/Data/Repository/GroupRepositoryImpl.cs index 596d33d..a15ec08 100644 --- a/Data/Repository/GroupRepositoryImpl.cs +++ b/Data/Repository/GroupRepositoryImpl.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Demo.Data.Repository { - public class GroupRepositoryImpl + public class GroupRepositoryImpl:IGroupRepository { public GroupRepositoryImpl() { @@ -17,6 +17,11 @@ namespace Demo.Data.Repository public List GetAllGroups { get; set; } + public List GetAllGroup() + { + return GetAllGroups; + } + public GroupLocalEntity? UpdateGroupName(GroupLocalEntity groupUpdateLocalEntity) { int index = GetAllGroups.FindIndex(x => x.Id == groupUpdateLocalEntity.Id); @@ -32,5 +37,22 @@ namespace Demo.Data.Repository GetAllGroups.Add(groupCreateLocalEntity); return groupCreateLocalEntity; } + + public bool RemoveGroupById(int groupID) + { + GroupLocalEntity? groupLocal = GetAllGroups + .Where(x => x.Id == groupID).FirstOrDefault(); + if (groupLocal == null) return false; + + return GetAllGroups.Remove(groupLocal); + } + + public GroupLocalEntity? GetGroupById(int groupID) { + GroupLocalEntity? groupLocal = GetAllGroups + .Where(x => x.Id == groupID).FirstOrDefault(); + if (groupLocal == null) return null; + + return groupLocal; + } } } diff --git a/Data/Repository/IGroupRepository.cs b/Data/Repository/IGroupRepository.cs new file mode 100644 index 0000000..58f990b --- /dev/null +++ b/Data/Repository/IGroupRepository.cs @@ -0,0 +1,18 @@ +using Demo.domain.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Demo.Data.Repository +{ + public interface IGroupRepository + { + List GetAllGroup(); + bool RemoveGroupById(int groupID); + GroupLocalEntity? UpdateGroupName(GroupLocalEntity updatedGroup); + GroupLocalEntity? GetGroupById(int groupID); + GroupLocalEntity? CreateGroup(GroupLocalEntity newGroup); + } +} \ No newline at end of file diff --git a/Data/Repository/IUserRepository.cs b/Data/Repository/IUserRepository.cs new file mode 100644 index 0000000..e69de29 diff --git a/Data/Repository/UserRepositoryImpl.cs b/Data/Repository/UserRepositoryImpl.cs index 5a5b9db..7b46f98 100644 --- a/Data/Repository/UserRepositoryImpl.cs +++ b/Data/Repository/UserRepositoryImpl.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Demo.Data.Repository { - public class UserRepositoryImpl + public class UserRepositoryImpl:IUserRepository { public UserRepositoryImpl() { @@ -17,6 +17,11 @@ namespace Demo.Data.Repository public List GetAllUsers { get; set; } + public List GetAllUser() + { + return GetAllUsers; + } + public bool RemoveUserByGuid(Guid userGuid) { UserLocalEntity? userLocal = GetAllUsers diff --git a/Domain/UseCase/UserUseCase.cs b/Domain/UseCase/UserUseCase.cs index eaa653f..89b23b7 100644 --- a/Domain/UseCase/UserUseCase.cs +++ b/Domain/UseCase/UserUseCase.cs @@ -10,8 +10,8 @@ namespace Demo.Domain.UseCase { public class UserUseCase { - private UserRepositoryImpl _repositoryUserImpl; - private GroupRepositoryImpl _repositoryGroupImpl; + private readonly UserRepositoryImpl _repositoryUserImpl; + private readonly GroupRepositoryImpl _repositoryGroupImpl; public UserUseCase(UserRepositoryImpl repositoryImpl, GroupRepositoryImpl repositoryGroupImpl) { @@ -19,7 +19,7 @@ namespace Demo.Domain.UseCase _repositoryGroupImpl = repositoryGroupImpl; } - public List GetAllGroups() => _repositoryGroupImpl.GetAllGroups + private List GetAllGroups() => _repositoryGroupImpl.GetAllGroups .Select(it => new Group { Id = it.Id, Name = it.Name}).ToList(); public List GetAllUsers() => _repositoryUserImpl.GetAllUsers .Join(_repositoryGroupImpl.GetAllGroups,