modal error

tpBlazor
Nicolas FRANCO 2 years ago
parent 9e0d0dfa4b
commit a7662f699e

@ -11,6 +11,7 @@
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" /> <link href="css/site.css" rel="stylesheet" />
<link href="BlazorTp1.styles.css" rel="stylesheet" /> <link href="BlazorTp1.styles.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head> </head>
<body> <body>
@ -34,7 +35,6 @@
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" /> <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" /> <link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<script src="_content/Blazored.Modal/blazored.modal.js"></script> <script src="_content/Blazored.Modal/blazored.modal.js"></script>
<script src="Components/Crafting.razor.js"></script> <script src="Components/Crafting.razor.js"></script>

@ -1,14 +1,12 @@
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Modal;
using Blazorise; using Blazorise;
using Blazorise.Bootstrap; using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome; using Blazorise.Icons.FontAwesome;
using BlazorTp1.Data; using BlazorTp1.Data;
using Blazored.Modal;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Localization;
using System.Globalization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System.Globalization;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -19,6 +17,8 @@ builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddHttpClient(); builder.Services.AddHttpClient();
builder.Services.AddBlazoredModal();
builder.Services builder.Services
.AddBlazorise() .AddBlazorise()
.AddBootstrapProviders() .AddBootstrapProviders()
@ -28,8 +28,6 @@ builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<IDataService, DataLocalService>(); builder.Services.AddScoped<IDataService, DataLocalService>();
builder.Services.AddBlazoredModal();
// Add the controller of the app // Add the controller of the app
builder.Services.AddControllers(); builder.Services.AddControllers();

@ -55,6 +55,16 @@ public class DataLocalService : IDataService
public async Task<int> Count() public async Task<int> Count()
{ {
// Load data from the local storage
var currentData = await _localStorage.GetItemAsync<Item[]>("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<Item[]>($"{_navigationManager.BaseUri}fake-data.json");
await _localStorage.SetItemAsync("data", originalData);
}
return (await _localStorage.GetItemAsync<Item[]>("data")).Length; return (await _localStorage.GetItemAsync<Item[]>("data")).Length;
} }

Loading…
Cancel
Save