IUserGroupsService + tests

This commit is contained in:
Artemy
2025-07-07 21:06:04 +07:00
parent a68feb4a17
commit 92c1ff6458
5 changed files with 121 additions and 13 deletions
@@ -0,0 +1,8 @@
using Govor.Core.Models;
namespace Govor.Application.Interfaces;
public interface IUserGroupsService
{
Task<List<ChatGroup>> GetUserGroupsAsync(Guid userId);
}
@@ -0,0 +1,28 @@
using Govor.Application.Interfaces;
using Govor.Core.Models;
using Govor.Core.Repositories.Groups;
using Govor.Data.Repositories.Exceptions;
namespace Govor.Application.Services;
public class UserGroupsService : IUserGroupsService
{
private readonly IGroupsRepository _groupRep;
public UserGroupsService(IGroupsRepository groupsRepository)
{
_groupRep = groupsRepository;
}
public async Task<List<ChatGroup>> GetUserGroupsAsync(Guid userId)
{
try
{
return await _groupRep.GetByUserIdAsync(userId);
}
catch (NotFoundByKeyException<Guid> ex)
{
return new List<ChatGroup>();
}
}
}