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.
125 lines
4.8 KiB
125 lines
4.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection.Metadata;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DTO;
|
|
using Dto2Entities;
|
|
using Entity;
|
|
using Shared;
|
|
|
|
namespace ServicesApi
|
|
{
|
|
public class QuoteService : IQuoteService<QuoteDTO>
|
|
{
|
|
private IQuoteService<Quote> quoteService;
|
|
|
|
public QuoteService(IQuoteService<Quote> quote)
|
|
{
|
|
quoteService = quote;
|
|
}
|
|
|
|
public async Task AddQuote(QuoteDTO quote)
|
|
{
|
|
await quoteService.AddQuote(quote.ToEntity());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetAllQuote()
|
|
{
|
|
var quotes = quoteService.GetAllQuote().Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetAllQuoteLang(int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.GetAllQuoteLang(index, pageSize,lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<QuoteDTO> GetDailyQuote(DateOnly date, int lang)
|
|
{
|
|
return quoteService.GetDailyQuote(date, lang).Result.ToDto();
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetFavorites(int index, int pageSize, int UserId)
|
|
{
|
|
var quotes = quoteService.GetFavorites(index, pageSize, UserId).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetInvalidQuote(int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.GetInvalidQuote(index, pageSize, lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetInvalidQuote(int index, int pageSize)
|
|
{
|
|
var quotes = quoteService.GetInvalidQuote(index, pageSize).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<int> GetLastQuoteId()
|
|
{
|
|
return await quoteService.GetLastQuoteId();
|
|
}
|
|
|
|
public async Task<QuoteDTO> GetQuoteById(int id)
|
|
{
|
|
return quoteService.GetQuoteById(id).Result.ToDto();
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetSomeQuote(int index, int pageSize)
|
|
{
|
|
var quotes = quoteService.GetSomeQuote(index, pageSize).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetSuggestions(int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.GetSuggestions(index, pageSize, lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> GetValidQuote(int index, int pageSize)
|
|
{
|
|
var quotes = quoteService.GetValidQuote(index, pageSize).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task RemoveQuote(int quoteId)
|
|
{
|
|
await quoteService.RemoveQuote(quoteId);
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> SearchByCharacter(string character, int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.SearchByCharacter(character, index, pageSize, lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> SearchByContent(string content, int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.SearchByContent(content, index, pageSize, lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task<PaginationResult<QuoteDTO>> SearchBySource(string source, int index, int pageSize, int lang)
|
|
{
|
|
var quotes = quoteService.SearchBySource(source, index, pageSize, lang).Result.items;
|
|
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
|
|
}
|
|
|
|
public async Task UpdateQuote(int quoteId, QuoteDTO quote)
|
|
{
|
|
await quoteService.UpdateQuote(quoteId, quote.ToEntity());
|
|
}
|
|
|
|
public async Task ValidateQuote(int quoteId, bool isValidate)
|
|
{
|
|
await quoteService.ValidateQuote(quoteId, isValidate);
|
|
}
|
|
}
|
|
}
|