|
|
|
@ -1,64 +1,66 @@
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using WF_WebAdmin.Model;
|
|
|
|
|
using static System.Net.WebRequestMethods;
|
|
|
|
|
|
|
|
|
|
namespace WF_WebAdmin.Service
|
|
|
|
|
{
|
|
|
|
|
public class QuoteServiceStub : IQuoteService
|
|
|
|
|
{
|
|
|
|
|
[Inject] public HttpClient Http { get; set; }
|
|
|
|
|
|
|
|
|
|
[Inject] public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
namespace WF_WebAdmin.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Task addQuote(Quote quote)
|
|
|
|
|
public class QuoteServiceStub : IQuoteServiceJson
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
private readonly string _jsonFilePath;
|
|
|
|
|
|
|
|
|
|
public Task removeQuote(Quote quote)
|
|
|
|
|
public QuoteServiceStub(string filePath)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
_jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task validQuote(Quote quote)
|
|
|
|
|
public async Task<List<User>> GetQuoteJson()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task updateQuote(Quote quote)
|
|
|
|
|
if (!File.Exists(_jsonFilePath))
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
Console.Out.WriteLine($"{_jsonFilePath} not found");
|
|
|
|
|
return new List<User>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getAllQuote()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var json = await File.ReadAllTextAsync(_jsonFilePath);
|
|
|
|
|
return JsonSerializer.Deserialize<List<User>>(json) ?? new List<User>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getSomeQuote(int nb, int page)
|
|
|
|
|
public async Task SaveQuoteJson(List<User> users)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var json = JsonSerializer.Serialize(users, new JsonSerializerOptions { WriteIndented = true });
|
|
|
|
|
await File.WriteAllTextAsync(_jsonFilePath, json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getOnequote(int id)
|
|
|
|
|
public async Task AddQuoteJson(User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var data = await GetQuoteJson();
|
|
|
|
|
user.Id = data.Count > 0 ? data.Max(p => p.Id) + 1 : 1;
|
|
|
|
|
data.Add(user);
|
|
|
|
|
await SaveQuoteJson(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> reserchQuote(string reserch, List<string> argument)
|
|
|
|
|
public async Task DeleteQuoteJson(int id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getAllQuoteInvalid()
|
|
|
|
|
var data = await GetQuoteJson();
|
|
|
|
|
var person = data.FirstOrDefault(p => p.Id == id);
|
|
|
|
|
if (person != null)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
data.Remove(person);
|
|
|
|
|
await SaveQuoteJson(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getSomeQuoteInvalid(int nb, int page)
|
|
|
|
|
public async Task UpdateQuoteJson(User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var data = await GetQuoteJson();
|
|
|
|
|
var person = data.FirstOrDefault(p => p.Id == user.Id);
|
|
|
|
|
if (person != null)
|
|
|
|
|
{
|
|
|
|
|
person.Name = user.Name;
|
|
|
|
|
person.Email = user.Email;
|
|
|
|
|
person.Image = user.Image;
|
|
|
|
|
await SaveQuoteJson(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|