|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Blazor.ViewClasses;
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
|
using static System.Net.WebRequestMethods;
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Services
|
|
|
|
@ -242,30 +243,29 @@ namespace Blazor.Services
|
|
|
|
|
return question;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public async Task Update(int id, QuestionsModel model)
|
|
|
|
|
//{
|
|
|
|
|
// // Get the current data
|
|
|
|
|
// var currentData = await _localStorage.GetItemAsync<List<Question>>("data");
|
|
|
|
|
public async Task Update(int id, QuestionModel model)
|
|
|
|
|
{
|
|
|
|
|
// Get the current data
|
|
|
|
|
var currentData = await _localStorage.GetItemAsync<List<Question>>("data");
|
|
|
|
|
|
|
|
|
|
// // Get the admin int the list
|
|
|
|
|
// var question = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
|
// Get the admin int the list
|
|
|
|
|
var question = currentData.FirstOrDefault(w => w.Id == id);
|
|
|
|
|
|
|
|
|
|
// // Check if admin exist
|
|
|
|
|
// if (question == null)
|
|
|
|
|
// {
|
|
|
|
|
// throw new Exception($"Unable to found the item with ID: {id}");
|
|
|
|
|
// }
|
|
|
|
|
// Check if admin exist
|
|
|
|
|
if (question == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Unable to found the item with ID: {id}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // Modify the content of the adminnistrator
|
|
|
|
|
// question.Username = model.Username;
|
|
|
|
|
// question.HashedPassword = model.HashedPassword;
|
|
|
|
|
// Modify the content of the adminnistrator
|
|
|
|
|
question.Content = model.Content;
|
|
|
|
|
|
|
|
|
|
// // Save the data
|
|
|
|
|
// await _localStorage.SetItemAsync("data", currentData);
|
|
|
|
|
//}
|
|
|
|
|
// Save the data
|
|
|
|
|
await _localStorage.SetItemAsync("data", currentData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public async Task Add(QuestionsModel model)
|
|
|
|
|
//{
|
|
|
|
|
public async Task Add(QuestionModel model)
|
|
|
|
|
{
|
|
|
|
|
// // Get the current data
|
|
|
|
|
// var currentData = await _localStorage.GetItemAsync<List<Question>>("data");
|
|
|
|
|
|
|
|
|
@ -283,7 +283,7 @@ namespace Blazor.Services
|
|
|
|
|
|
|
|
|
|
// // Save the data
|
|
|
|
|
// await _localStorage.SetItemAsync("data", currentData);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<int> CountQuestion()
|
|
|
|
|
{
|
|
|
|
|