Interfaces user, group
This commit is contained in:
parent
7603d4fbad
commit
be284427eb
@ -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<GroupLocalEntity> GetAllGroups
|
||||
{ get; set; }
|
||||
|
||||
public List<GroupLocalEntity> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
Data/Repository/IGroupRepository.cs
Normal file
18
Data/Repository/IGroupRepository.cs
Normal file
@ -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<GroupLocalEntity> GetAllGroup();
|
||||
bool RemoveGroupById(int groupID);
|
||||
GroupLocalEntity? UpdateGroupName(GroupLocalEntity updatedGroup);
|
||||
GroupLocalEntity? GetGroupById(int groupID);
|
||||
GroupLocalEntity? CreateGroup(GroupLocalEntity newGroup);
|
||||
}
|
||||
}
|
0
Data/Repository/IUserRepository.cs
Normal file
0
Data/Repository/IUserRepository.cs
Normal file
@ -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<UserLocalEntity> GetAllUsers
|
||||
{ get; set; }
|
||||
|
||||
public List<UserLocalEntity> GetAllUser()
|
||||
{
|
||||
return GetAllUsers;
|
||||
}
|
||||
|
||||
public bool RemoveUserByGuid(Guid userGuid)
|
||||
{
|
||||
UserLocalEntity? userLocal = GetAllUsers
|
||||
|
@ -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<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups
|
||||
private List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups
|
||||
.Select(it => new Group { Id = it.Id, Name = it.Name}).ToList();
|
||||
public List<User> GetAllUsers() => _repositoryUserImpl.GetAllUsers
|
||||
.Join(_repositoryGroupImpl.GetAllGroups,
|
||||
|
Loading…
Reference in New Issue
Block a user