You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.7 KiB
59 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DTO;
|
|
using Entity;
|
|
using Shared;
|
|
using Dto2Entities;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace ServicesApi
|
|
{
|
|
public class FavoriteService : IFavoriteService<QuoteDTO>
|
|
{
|
|
|
|
private IFavoriteService<Quote> favoriteService;
|
|
|
|
public FavoriteService(IFavoriteService<Quote> favorite)
|
|
{
|
|
favoriteService = favorite;
|
|
}
|
|
|
|
|
|
public async Task AddFavorite(int quoteid, int userId)
|
|
{
|
|
await favoriteService.AddFavorite(quoteid, userId);
|
|
}
|
|
|
|
public async Task RemoveAllFavoriteForQuote(int quoteId)
|
|
{
|
|
await favoriteService.RemoveAllFavoriteForQuote(quoteId);
|
|
}
|
|
|
|
public async Task RemoveAllFavoriteForUser(int userId)
|
|
{
|
|
await favoriteService.RemoveAllFavoriteForUser(userId);
|
|
}
|
|
|
|
public async Task RemoveFavorite(int quoteid, int userId)
|
|
{
|
|
await favoriteService.RemoveFavorite(quoteid, userId);
|
|
}
|
|
|
|
public async Task<QuoteDTO?> GetFavorite(int userId, int idQuote)
|
|
{
|
|
return (await favoriteService.GetFavorite(userId,idQuote) ).ToDto();
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetFavoriteByIdUser(int userId, int index, int count)
|
|
{
|
|
var fav = (await favoriteService.GetFavoriteByIdUser(userId, index, count)).items;
|
|
return new PaginationResult<QuoteDTO>(fav.Count(), 0, 10, fav.ToDto());
|
|
|
|
}
|
|
}
|
|
}
|