68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using AutoMapper;
|
|
using IM_API.Dtos;
|
|
using IM_API.Interface.Services;
|
|
using IM_API.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace IM_API.Services
|
|
{
|
|
public class FriendService : IFriendSerivce
|
|
{
|
|
private readonly ImContext _context;
|
|
private readonly ILogger<FriendService> _logger;
|
|
private readonly IMapper _mapper;
|
|
public FriendService(ImContext context, ILogger<FriendService> logger, IMapper mapper)
|
|
{
|
|
_context = context;
|
|
_logger = logger;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
public Task<bool> BlockeFriendAsync(int friendId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> BlockFriendByUserIdAsync(int userId, int toUserId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> DeleteFriendAsync(int friendId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> DeleteFriendByUserIdAsync(int userId, int toUserId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public async Task<List<FriendInfoDto>> GetFriendListAsync(int userId, int page, int limit, bool desc)
|
|
{
|
|
var query = _context.Friends.Where(x => x.UserId == userId);
|
|
if (desc)
|
|
{
|
|
query = query.OrderByDescending(x => x.UserId);
|
|
}
|
|
var friendList = await query.Skip((page - 1 * limit)).Take(limit).ToListAsync();
|
|
return _mapper.Map<List<FriendInfoDto>>(friendList);
|
|
}
|
|
|
|
public Task<FriendRequest> GetFriendRequestListAsync(int userId, bool isReceived, int page, int limit, bool desc)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> HandleFriendRequestAsync(HandleFriendRequestDto requestDto)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> SendFriendRequestAsync(FriendRequestDto friendRequest)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|