Service des citations
continuous-integration/drone/push Build is failing Details

pull/6/head
Leni BEAULATON 4 weeks ago
parent 69716c4f9b
commit 4b1edf0e16

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;
using Shared;
namespace Contextlib
{
public class DbQuoteManager : IQuoteService<Quote>
{
private WTFContext _context;
private GenericRepository<Quote> _repo;
public DbQuoteManager(WTFContext context)
{
_context = context ?? throw new ArgumentNullException(nameof(context), "Database context cannot be null.");
_repo = new GenericRepository<Quote>(_context);
}
public async Task AddQuote(Quote quote)
{
if (quote == null)
{
throw new ArgumentNullException(nameof(quote), "quote cannot be null.");
}
_repo.Insert(quote);
await _context.SaveChangesAsync();
}
public async Task<PaginationResult<Quote>> GetAllQuote()
{
List<Quote> quotes = _repo.GetItems(0, _repo.Count(), [nameof(Quote.Id)]).ToList();
return new PaginationResult<Quote>(quotes.Count, 0, quotes.Count, quotes);
}
public async Task<PaginationResult<Quote>> GetAllQuoteLang(int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task<Quote> GetDailyQuote(DateOnly date, int lang)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetFavorites(int index, int pageSize, int UserId)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetInvalidQuote(int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetInvalidQuote(int index, int pageSize)
{
throw new NotImplementedException();
}
public async Task<int> GetLastQuoteId()
{
throw new NotImplementedException();
}
public async Task<Quote> GetQuoteById(int id)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetSomeQuote(int index, int pageSize)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetSuggestions(int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> GetValidQuote(int index, int pageSize)
{
throw new NotImplementedException();
}
public async Task RemoveQuote(int quoteId)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> SearchByCharacter(string character, int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> SearchByContent(string content, int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task<PaginationResult<Quote>> SearchBySource(string source, int index, int pageSize, int lang)
{
throw new NotImplementedException();
}
public async Task UpdateQuote(int quoteId, Quote quote)
{
throw new NotImplementedException();
}
public async Task ValidateQuote(int quoteId, bool isValidate)
{
throw new NotImplementedException();
}
}
}

@ -19,6 +19,8 @@ namespace Contextlib
_repo = new GenericRepository<Users>(_context); _repo = new GenericRepository<Users>(_context);
} }
public async Task AddUser(Users user) public async Task AddUser(Users user)
{ {
if (user == null) { if (user == null) {

@ -26,7 +26,8 @@ namespace ServicesApi
public async Task<PaginationResult<QuoteDTO>> GetAllQuote() public async Task<PaginationResult<QuoteDTO>> GetAllQuote()
{ {
throw new NotImplementedException(); 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) public async Task<PaginationResult<QuoteDTO>> GetAllQuoteLang(int index, int pageSize, int lang)
@ -41,17 +42,20 @@ namespace ServicesApi
public async Task<PaginationResult<QuoteDTO>> GetFavorites(int index, int pageSize, int UserId) public async Task<PaginationResult<QuoteDTO>> GetFavorites(int index, int pageSize, int UserId)
{ {
throw new NotImplementedException(); 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) public async Task<PaginationResult<QuoteDTO>> GetInvalidQuote(int index, int pageSize, int lang)
{ {
throw new NotImplementedException(); 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) public async Task<PaginationResult<QuoteDTO>> GetInvalidQuote(int index, int pageSize)
{ {
throw new NotImplementedException(); var quotes = quoteService.GetInvalidQuote(index, pageSize).Result.items;
return new PaginationResult<QuoteDTO>(quotes.Count(), 0, 10, quotes.ToDto());
} }
public async Task<int> GetLastQuoteId() public async Task<int> GetLastQuoteId()
@ -66,12 +70,14 @@ namespace ServicesApi
public async Task<PaginationResult<QuoteDTO>> GetSomeQuote(int index, int pageSize) public async Task<PaginationResult<QuoteDTO>> GetSomeQuote(int index, int pageSize)
{ {
throw new NotImplementedException(); 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) public async Task<PaginationResult<QuoteDTO>> GetSuggestions(int index, int pageSize, int lang)
{ {
throw new NotImplementedException(); 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) public async Task<PaginationResult<QuoteDTO>> GetValidQuote(int index, int pageSize)

@ -8,15 +8,15 @@ using ServicesApi;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
//API //API
builder.Services.AddScoped<IUserService<UserDTO>, UserService>(); builder.Services.AddScoped<IUserService<UserDTO>, UserService>();
builder.Services.AddScoped<IQuoteService<QuoteDTO>, QuoteServiceStub>(); // Retirer "Stub" builder.Services.AddScoped<IQuoteService<QuoteDTO>, QuoteService>();
//EF //EF
builder.Services.AddScoped<WTFContext, StubWTFContext>(); builder.Services.AddScoped<WTFContext, StubWTFContext>();
builder.Services.AddScoped<IUserService<Users>, DbUsersManager>(); builder.Services.AddScoped<IUserService<Users>, DbUsersManager>();
// builder.Services.AddScoped<IUserService<Quote>, DbQuoteManager>(); Quand DbQuoteManager sera présent builder.Services.AddScoped<IQuoteService<Quote>, DbQuoteManager>();
//builder.Services.AddScoped<IUserService<Character>, DbCharacterManager>(); //builder.Services.AddScoped<ICharacterService<Character>, DbCharacterManager>();
//builder.Services.AddScoped<IUserService<Commentary>, DbCommentaryManager>(); //builder.Services.AddScoped<ICommentaryService<Commentary>, DbCommentaryManager>();
//... //...
// Add services to the container. // Add services to the container.

Loading…
Cancel
Save