-
- An error has occurred. This application may no longer respond until reloaded.
-
-
- An unhandled exception has occurred. See browser dev tools for details.
-
- Reload
- 🗙
-
+
+ An error has occurred. This application may no longer respond until reloaded.
+
+
+ An unhandled exception has occurred. See browser dev tools for details.
+
+ Reload
+ 🗙
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BlazorTp1/Program.cs b/BlazorTp1/Program.cs
index e3cd109..97cb8f6 100644
--- a/BlazorTp1/Program.cs
+++ b/BlazorTp1/Program.cs
@@ -1,14 +1,12 @@
using Blazored.LocalStorage;
+using Blazored.Modal;
using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;
using BlazorTp1.Data;
-using Blazored.Modal;
-using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Localization;
-using System.Globalization;
using Microsoft.Extensions.Options;
+using System.Globalization;
var builder = WebApplication.CreateBuilder(args);
@@ -19,6 +17,8 @@ builder.Services.AddSingleton();
builder.Services.AddHttpClient();
+builder.Services.AddBlazoredModal();
+
builder.Services
.AddBlazorise()
.AddBootstrapProviders()
@@ -28,8 +28,6 @@ builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped();
-builder.Services.AddBlazoredModal();
-
// Add the controller of the app
builder.Services.AddControllers();
diff --git a/BlazorTp1/Services/DataLocalService.cs b/BlazorTp1/Services/DataLocalService.cs
index 13f109d..9154eb7 100644
--- a/BlazorTp1/Services/DataLocalService.cs
+++ b/BlazorTp1/Services/DataLocalService.cs
@@ -55,6 +55,16 @@ public class DataLocalService : IDataService
public async Task Count()
{
+ // Load data from the local storage
+ var currentData = await _localStorage.GetItemAsync("data");
+
+ // Check if data exist in the local storage
+ if (currentData == null)
+ {
+ // this code add in the local storage the fake data
+ var originalData = await _http.GetFromJsonAsync($"{_navigationManager.BaseUri}fake-data.json");
+ await _localStorage.SetItemAsync("data", originalData);
+ }
return (await _localStorage.GetItemAsync("data")).Length;
}