38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using GroupService.Domain.Entities;
|
|
using GroupService.Domain.IReposities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace GroupService.Infrastructure.Reposities
|
|
{
|
|
public class GroupInvitationReposity : IGroupInvitationReposity
|
|
{
|
|
private readonly GroupDbContext db;
|
|
|
|
public GroupInvitationReposity(GroupDbContext db)
|
|
{
|
|
this.db = db;
|
|
}
|
|
|
|
public void Create(GroupInvitation invitation)
|
|
{
|
|
db.GroupInvitations.Add(invitation);
|
|
}
|
|
|
|
public void CreateRange(IEnumerable<GroupInvitation> invitations)
|
|
{
|
|
db.GroupInvitations.AddRange(invitations);
|
|
}
|
|
|
|
public async Task<GroupInvitation?> FindByIdAsync(Guid id)
|
|
{
|
|
return await db.GroupInvitations.FirstOrDefaultAsync(x => x.Id == id);
|
|
}
|
|
|
|
public async Task<GroupInvitation?> FindByGroupIdAndUserIdAsync(Guid groupId, Guid userId)
|
|
{
|
|
return await db.GroupInvitations.FirstOrDefaultAsync(
|
|
x => x.GroupId == groupId && x.UserId == userId);
|
|
}
|
|
}
|
|
}
|