添加项目文件。
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using ContactService.Domain;
|
||||
using ContactService.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ContactService.Infrastructure
|
||||
{
|
||||
public class FriendRequestReposity : IFriendRequestReposity
|
||||
{
|
||||
private readonly ContactDbContext db;
|
||||
|
||||
public FriendRequestReposity(ContactDbContext db)
|
||||
{
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public async Task<bool> CreateAsync(FriendRequest friendRequest)
|
||||
{
|
||||
db.Add(friendRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Task<FriendRequest?> FindByIdAsync(Guid id)
|
||||
{
|
||||
return db.FriendRequests.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FriendRequest>> FindByOwnerIdAsync(Guid ownerId)
|
||||
{
|
||||
return await db.FriendRequests.Where(x => x.OwnerId == ownerId).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FriendRequest>> FindByTargetIdAsync(Guid targetId)
|
||||
{
|
||||
return await db.FriendRequests.Where(x => x.TargetId == targetId).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user