|
|
@ -1,4 +1,5 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
using System.Security.Cryptography;
|
|
|
@ -49,10 +50,11 @@ namespace Contextlib
|
|
|
|
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 = await _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)
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
.ToListAsync();
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
Quote quote = quotes[date.DayNumber % quotes.Count()];
|
|
|
|
Quote quote = quotes[date.DayNumber % quotes.Count()];
|
|
|
@ -61,6 +63,11 @@ namespace Contextlib
|
|
|
|
.FirstOrDefaultAsync() ?? quotes.First();*/
|
|
|
|
.FirstOrDefaultAsync() ?? quotes.First();*/
|
|
|
|
|
|
|
|
|
|
|
|
//Quote quote = _repo.GetById(date.DayNumber % quotes.Count()) ?? quotes.First();
|
|
|
|
//Quote quote = _repo.GetById(date.DayNumber % quotes.Count()) ?? quotes.First();
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
if (quotes.Count() == 0) return null;
|
|
|
|
|
|
|
|
Quote quote = quotes[ date.DayNumber % quotes.Count() ] ;
|
|
|
|
|
|
|
|
>>>>>>> 8471e6cfd50227037555f6650ed659ac091cc613
|
|
|
|
|
|
|
|
|
|
|
|
return quote;
|
|
|
|
return quote;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,10 +134,11 @@ namespace Contextlib
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
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) // A changer Suggestion Random
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang)
|
|
|
|
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
|
|
|
|
.Include(q => q.Source).Include(q => q.Character).ThenInclude(c => c.Images)
|
|
|
|
|
|
|
|
//.OrderBy(q=> new Random() )
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
.Skip(index * pageSize).Take(pageSize).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
@ -145,39 +153,91 @@ namespace Contextlib
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
return new PaginationResult<Quote>(quotes.Count, index, pageSize, quotes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> SearchByCharacter(string character, int index, int pageSize, int lang)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage==(LangEnum)lang && (item.Character.Name).Contains(character))
|
|
|
|
|
|
|
|
.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>> SearchByContent(string content, int index, int pageSize, int lang)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang && (item.Content).Contains(content))
|
|
|
|
|
|
|
|
.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>> SearchBySource(string source, int index, int pageSize, int lang)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<Quote> quotes = _context.quotes.Where(item => item.IsValid && item.Langage == (LangEnum)lang && (item.Source.Title).Contains(source))
|
|
|
|
|
|
|
|
.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 RemoveQuote(int quoteId)
|
|
|
|
public async Task RemoveQuote(int quoteId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_repo.Delete(quoteId);
|
|
|
|
|
|
|
|
|
|
|
|
_repo.Delete( _repo.GetById(quoteId) );
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PaginationResult<Quote>> SearchByCharacter(string character, int index, int pageSize, int lang)
|
|
|
|
public async Task UpdateQuote(int quoteId, Quote quote)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Quote? q = _repo.GetById(quoteId);
|
|
|
|
|
|
|
|
if (q != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
bool change = false;
|
|
|
|
|
|
|
|
if (quote.IdSource != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
q.IdSource = quote.IdSource;
|
|
|
|
|
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quote.IdCharacter != 0)
|
|
|
|
public async Task<PaginationResult<Quote>> SearchByContent(string content, int index, int pageSize, int lang)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
q.IdCharacter = quote.IdCharacter;
|
|
|
|
|
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quote.IdSource != 0)
|
|
|
|
public async Task<PaginationResult<Quote>> SearchBySource(string source, int index, int pageSize, int lang)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
q.IdSource = quote.IdSource;
|
|
|
|
|
|
|
|
change = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quote.IdUsersPropose !=0)
|
|
|
|
public async Task UpdateQuote(int quoteId, Quote quote)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
q.IdUsersPropose = quote.IdUsersPropose;
|
|
|
|
|
|
|
|
change = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quote.Content != null || quote.Content =="")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
q.Content = quote.Content;
|
|
|
|
|
|
|
|
change = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_repo.Update(q);
|
|
|
|
|
|
|
|
if (change) _context.SaveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task ValidateQuote(int quoteId, bool isValidate)
|
|
|
|
public async Task ValidateQuote(int quoteId, bool isValidate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
Quote? q = _repo.GetById(quoteId);
|
|
|
|
|
|
|
|
if (q != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
q.IsValid = isValidate;
|
|
|
|
|
|
|
|
_repo.Update(q);
|
|
|
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|