|
|
@ -1,6 +1,7 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Entity;
|
|
|
|
using Entity;
|
|
|
@ -42,18 +43,24 @@ namespace Contextlib
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> GetAllQuoteLang(int index, int pageSize, int lang)
|
|
|
|
public async Task<PaginationResult<Quote>> GetAllQuoteLang(int index, int pageSize, int lang)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
List<Quote> quotes = await _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images)
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images)
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToListAsync();
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<Quote> GetDailyQuote(DateOnly date, int lang)
|
|
|
|
public async Task<Quote> GetDailyQuote(DateOnly date, int lang)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
List<Quote> quotes = await _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images).Include(q => q.Favorite)
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images).Include(q => q.Favorite)
|
|
|
|
.ToList();
|
|
|
|
.ToListAsync();
|
|
|
|
Quote quote = _repo.GetById(date.DayNumber % quotes.Count()) ?? quotes.First();
|
|
|
|
|
|
|
|
|
|
|
|
Quote quote = quotes[date.DayNumber % quotes.Count()];
|
|
|
|
|
|
|
|
/*Quote quote = await _context.quotes.Where(item => item.Id == date.DayNumber % quotes.Count())
|
|
|
|
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images).Include(q => q.Favorite)
|
|
|
|
|
|
|
|
.FirstOrDefaultAsync() ?? quotes.First();*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Quote quote = _repo.GetById(date.DayNumber % quotes.Count()) ?? quotes.First();
|
|
|
|
|
|
|
|
|
|
|
|
return quote;
|
|
|
|
return quote;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -113,17 +120,29 @@ namespace Contextlib
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> GetSomeQuote(int index, int pageSize)
|
|
|
|
public async Task<PaginationResult<Quote>> GetSomeQuote(int index, int pageSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid)
|
|
|
|
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images)
|
|
|
|
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> GetSuggestions(int index, int pageSize, int lang)
|
|
|
|
public async Task<PaginationResult<Quote>> GetSuggestions(int index, int pageSize, int lang)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images) // rajouter un mélange random
|
|
|
|
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> GetValidQuote(int index, int pageSize)
|
|
|
|
public async Task<PaginationResult<Quote>> GetValidQuote(int index, int pageSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid)
|
|
|
|
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images)
|
|
|
|
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -132,7 +151,8 @@ namespace Contextlib
|
|
|
|
|
|
|
|
|
|
|
|
public async Task RemoveQuote(int quoteId)
|
|
|
|
public async Task RemoveQuote(int quoteId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
_repo.Delete(quoteId);
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> SearchByCharacter(string character, int index, int pageSize, int lang)
|
|
|
|
public async Task<PaginationResult<Quote>> SearchByCharacter(string character, int index, int pageSize, int lang)
|
|
|
|