Created endpoints to manage friends
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using Ardalis.Specification;
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Specifications.Friends;
|
||||
|
||||
public class GetFriendByCriteriaSpec : SingleResultSpecification<UserFriend>
|
||||
{
|
||||
public GetFriendByCriteriaSpec(int userId, int friendId)
|
||||
{
|
||||
Query
|
||||
.Where(x => x.UserId == userId && x.FriendId == friendId && x.IsAccepted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Ardalis.Specification;
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Specifications.Friends;
|
||||
|
||||
public class GetFriendRequestByIdsSpec : SingleResultSpecification<UserFriend>
|
||||
{
|
||||
public GetFriendRequestByIdsSpec(int userId, int friendId)
|
||||
{
|
||||
Query
|
||||
.Where(x => x.UserId == userId && x.FriendId == friendId && !x.IsAccepted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Ardalis.Specification;
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Specifications.Friends;
|
||||
|
||||
public class GetFriendRequestSpec : Specification<UserFriend>
|
||||
{
|
||||
public GetFriendRequestSpec(int friendId)
|
||||
{
|
||||
Query
|
||||
.Include(x => x.User)
|
||||
.Where(x => !x.IsAccepted && x.FriendId == friendId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Ardalis.Specification;
|
||||
using BeReadyBackend.Models;
|
||||
|
||||
namespace BeReadyBackend.Specifications.Friends;
|
||||
|
||||
public class GetFriendsByUserIdSpec : Specification<UserFriend>
|
||||
{
|
||||
public GetFriendsByUserIdSpec(int userId)
|
||||
{
|
||||
Query
|
||||
.Include(x => x.User)
|
||||
.Include(x => x.Friend)
|
||||
.Where(x => x.UserId == userId && x.IsAccepted);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user