41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using GroupService.Domain.Entities;
|
|
using GroupService.Domain.IReposities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace GroupService.Infrastructure.Reposities
|
|
{
|
|
public class GroupJoinRequestReposity : IGroupRequestReposity
|
|
{
|
|
private readonly GroupDbContext db;
|
|
|
|
public GroupJoinRequestReposity(GroupDbContext db)
|
|
{
|
|
this.db = db;
|
|
}
|
|
|
|
public void Create(GroupJoinRequest request)
|
|
{
|
|
db.GroupJoinRequests.Add(request);
|
|
}
|
|
|
|
public async Task<IEnumerable<GroupJoinRequest>> FindByGroupIdAsync(Guid groupId)
|
|
{
|
|
return await db.GroupJoinRequests.Where(x => x.GroupId == groupId)
|
|
.OrderByDescending(o => o.CreationTime)
|
|
.ToListAsync();
|
|
}
|
|
|
|
public async Task<GroupJoinRequest?> FindByIdAsync(Guid id)
|
|
{
|
|
return await db.GroupJoinRequests.FirstOrDefaultAsync(x => x.Id == id);
|
|
}
|
|
|
|
public async Task<IEnumerable<GroupJoinRequest>> FindByUserIdAsync(Guid userId)
|
|
{
|
|
return await db.GroupJoinRequests.Where(x =>
|
|
x.UserId == userId || x.OperatorId == userId
|
|
).ToListAsync();
|
|
}
|
|
}
|
|
}
|