Compare commits

..

2 Commits

Author SHA1 Message Date
adm
1547eaee8d merger 2024-10-21 11:06:42 +03:00
adm
74e3d94f9a add group interface 2024-10-21 11:04:44 +03:00
5 changed files with 56 additions and 7 deletions

View File

@ -8,8 +8,33 @@ using System.Threading.Tasks;
namespace Demo.Data.Repository
{
public class GroupRepositoryImpl
public class GroupRepositoryImpl:IGroupRepository
{
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public bool AddGroup(GroupLocalEntity newGroup)
{
throw new NotImplementedException();
}
public List<GroupLocalEntity> GetAllGroup()
{
throw new NotImplementedException();
}
public List<GroupLocalEntity> GetAllGroups() => LocalStaticData.groups;
public GroupLocalEntity GetGroupById(int groupID)
{
throw new NotImplementedException();
}
public bool RemoveGroupById(int groupID)
{
throw new NotImplementedException();
}
public bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup)
{
throw new NotImplementedException();
}
}
}

View 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);
bool UpdateGroupById(int groupID, GroupLocalEntity updatedGroup);
GroupLocalEntity GetGroupById(int groupID);
bool AddGroup(GroupLocalEntity newGroup);
}
}

View File

@ -11,4 +11,8 @@
<Folder Include="Data\RemoteData\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
</ItemGroup>
</Project>

View File

@ -10,19 +10,19 @@ namespace Demo.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)
public UserUseCase(UserRepositoryImpl repositoryImpl, IGroupRepository repositoryGroupImpl)
{
_repositoryUserImpl = repositoryImpl;
_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) =>

View File

@ -3,6 +3,8 @@ using Demo.Data.Repository;
using Demo.Domain.UseCase;
using Demo.UI;
GroupRepositoryImpl groupRepositoryImpl = new GroupRepositoryImpl();
UserRepositoryImpl userRepositoryImpl = new UserRepositoryImpl();
UserUseCase userUseCase = new UserUseCase(userRepositoryImpl, groupRepositoryImpl);