|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Blazor.Models;
|
|
|
|
|
using Blazor.Pages;
|
|
|
|
|
using Blazor.ViewClasses;
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
@ -12,24 +13,21 @@ namespace Blazor.Services
|
|
|
|
|
private readonly HttpClient _http;
|
|
|
|
|
private readonly ILocalStorageService _localStorage;
|
|
|
|
|
private readonly NavigationManager _navigationManager;
|
|
|
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
|
|
|
|
|
|
public DataLocalService(
|
|
|
|
|
ILocalStorageService localStorage,
|
|
|
|
|
HttpClient http,
|
|
|
|
|
IWebHostEnvironment webHostEnvironment,
|
|
|
|
|
NavigationManager navigationManager)
|
|
|
|
|
{
|
|
|
|
|
_localStorage = localStorage;
|
|
|
|
|
_http = http;
|
|
|
|
|
_webHostEnvironment = webHostEnvironment;
|
|
|
|
|
_navigationManager = navigationManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<Chapter> GetById(int id)
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
|
|
// Get the chapter int the list
|
|
|
|
|
var chapter = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
@ -89,7 +87,7 @@ namespace Blazor.Services
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
//var currentData = await _localStorage.GetItemAsync<List<Chapter>>("data");
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Chapter>>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters"+"/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
|
|
// Get the chapter int the list
|
|
|
|
|
var chapter = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
@ -136,7 +134,7 @@ namespace Blazor.Services
|
|
|
|
|
public async Task<Administrator> GetAdminById(int id)
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Administrator>>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Administrator>>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators"+"/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
|
|
// Get the admin int the list
|
|
|
|
|
var admin = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
@ -229,7 +227,7 @@ namespace Blazor.Services
|
|
|
|
|
public async Task<Question> GetQuestionById(int id)
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Question>>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Question>>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions"+"/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
|
|
// Get the question int the list
|
|
|
|
|
var question = currentData.FirstOrDefault(w => w.Q_id == id);
|
|
|
|
@ -321,7 +319,7 @@ namespace Blazor.Services
|
|
|
|
|
public async Task<Player> GetPlayerById(int id)
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Player>>($"https://trusting-panini.87-106-126-109.plesk.page/api/players/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var currentData = _http.GetFromJsonAsync<List<Player>>($"https://trusting-panini.87-106-126-109.plesk.page/api/players"+"/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
|
|
// Get the player in the list
|
|
|
|
|
var player = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
|