Created endpoints to manage friends

This commit is contained in:
2026-02-22 12:02:44 +01:00
parent a701909d9d
commit f1ef5302c1
19 changed files with 283 additions and 45 deletions
@@ -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);
}
}