diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3f2db9a Binary files /dev/null and b/.DS_Store differ diff --git a/BlazorTuto/Components/CraftingItem.razor b/BlazorTuto/Components/CraftingItem.razor index fb86eec..a010739 100644 --- a/BlazorTuto/Components/CraftingItem.razor +++ b/BlazorTuto/Components/CraftingItem.razor @@ -10,6 +10,6 @@ @if (Item != null) { // @Item.DisplayName - @Item.DisplayName - } + @Item.DisplayName + } diff --git a/BlazorTuto/Components/ShowItems.razor b/BlazorTuto/Components/ShowItems.razor deleted file mode 100644 index 62d31ba..0000000 --- a/BlazorTuto/Components/ShowItems.razor +++ /dev/null @@ -1,11 +0,0 @@ -@typeparam TItem - -
- @if ((Items?.Count ?? 0) != 0) - { - @foreach (var item in Items) - { - @ShowTemplate(item); - } - } -
\ No newline at end of file diff --git a/BlazorTuto/Components/ShowItems.razor.cs b/BlazorTuto/Components/ShowItems.razor.cs deleted file mode 100644 index 607f1b5..0000000 --- a/BlazorTuto/Components/ShowItems.razor.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace BlazorTuto.Components -{ - public partial class ShowItems - { - [Parameter] - public List Items { get; set; } - - [Parameter] - public RenderFragment ShowTemplate { get; set; } - } -} diff --git a/BlazorTuto/Data/WeatherForecast.cs b/BlazorTuto/Data/WeatherForecast.cs deleted file mode 100644 index e6282a5..0000000 --- a/BlazorTuto/Data/WeatherForecast.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace BlazorTuto.Data -{ - public class WeatherForecast - { - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string? Summary { get; set; } - } -} \ No newline at end of file diff --git a/BlazorTuto/Data/WeatherForecastService.cs b/BlazorTuto/Data/WeatherForecastService.cs deleted file mode 100644 index 06f0761..0000000 --- a/BlazorTuto/Data/WeatherForecastService.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace BlazorTuto.Data -{ - public class WeatherForecastService - { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - public Task GetForecastAsync(DateTime startDate) - { - return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = Summaries[Random.Shared.Next(Summaries.Length)] - }).ToArray()); - } - } -} \ No newline at end of file diff --git a/BlazorTuto/Models/Cake.cs b/BlazorTuto/Models/Cake.cs deleted file mode 100644 index 7bbf40d..0000000 --- a/BlazorTuto/Models/Cake.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BlazorTuto.Models -{ - public class Cake - { - public int Id { get; set; } - public string Name { get; set; } - public decimal Cost { get; set; } - } -} diff --git a/BlazorTuto/Pages/Counter.razor b/BlazorTuto/Pages/Counter.razor deleted file mode 100644 index b21f052..0000000 --- a/BlazorTuto/Pages/Counter.razor +++ /dev/null @@ -1,18 +0,0 @@ -@page "/counter" - -Counter - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/BlazorTuto/Pages/Edit.razor.cs b/BlazorTuto/Pages/Edit.razor.cs index bac11c4..578b542 100644 --- a/BlazorTuto/Pages/Edit.razor.cs +++ b/BlazorTuto/Pages/Edit.razor.cs @@ -45,11 +45,6 @@ namespace BlazorTuto.Pages var fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/default.png"); - if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{itemModel.Name}.png")) - { - fileContent = await File.ReadAllBytesAsync($"{WebHostEnvironment.WebRootPath}/images/{item.Name}.png"); - } - // Set the model with the item itemModel = ItemFactory.ToModel(item, fileContent); } diff --git a/BlazorTuto/Pages/FetchData.razor b/BlazorTuto/Pages/FetchData.razor deleted file mode 100644 index 48faeb1..0000000 --- a/BlazorTuto/Pages/FetchData.razor +++ /dev/null @@ -1,48 +0,0 @@ -@page "/fetchdata" - -Weather forecast - -@using BlazorTuto.Data -@inject WeatherForecastService ForecastService - -

Weather forecast

- -

This component demonstrates fetching data from a service.

- -@if (forecasts == null) -{ -

Loading...

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - forecasts = await ForecastService.GetForecastAsync(DateTime.Now); - } -} diff --git a/BlazorTuto/Pages/List.razor b/BlazorTuto/Pages/List.razor index 8ba376e..82ce152 100644 --- a/BlazorTuto/Pages/List.razor +++ b/BlazorTuto/Pages/List.razor @@ -25,7 +25,7 @@ } else { - @context.DisplayName + @context.DisplayName } diff --git a/BlazorTuto/Pages/List.razor.cs b/BlazorTuto/Pages/List.razor.cs index c345663..bf364f8 100644 --- a/BlazorTuto/Pages/List.razor.cs +++ b/BlazorTuto/Pages/List.razor.cs @@ -69,8 +69,8 @@ namespace BlazorTuto.Pages if (!e.CancellationToken.IsCancellationRequested) { - totalItem = (await LocalStorage.GetItemAsync>("data")).Count; - items = new List(response); // an actual data for the current page + items = await DataService.List(e.Page, e.PageSize); + totalItem = await DataService.Count(); } } diff --git a/BlazorTuto/Program.cs b/BlazorTuto/Program.cs index f8cb3df..7e0872c 100644 --- a/BlazorTuto/Program.cs +++ b/BlazorTuto/Program.cs @@ -2,7 +2,6 @@ using Blazored.LocalStorage; using Blazorise; using Blazorise.Bootstrap; using Blazorise.Icons.FontAwesome; -using BlazorTuto.Data; using BlazorTuto.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; @@ -16,7 +15,6 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); -builder.Services.AddSingleton(); builder.Services.AddHttpClient(); builder.Services .AddBlazorise() diff --git a/BlazorTuto/Properties/launchSettings.json b/BlazorTuto/Properties/launchSettings.json index 6c7c4c5..3a4542b 100644 --- a/BlazorTuto/Properties/launchSettings.json +++ b/BlazorTuto/Properties/launchSettings.json @@ -1,35 +1,33 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:18767", - "sslPort": 44327 - } - }, - "profiles": { - "BlazorTuto": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:7082;http://localhost:5082", - "dotnetRunMessages": true - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Docker": { - "commandName": "Docker", - "launchBrowser": true, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", - "publishAllPorts": true, - "useSSL": true - } - } +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:18767", + "sslPort": 44327 + } + }, + "profiles": { + "BlazorTuto": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "https://localhost:7082;http://localhost:5082", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": {} + } + } } \ No newline at end of file diff --git a/BlazorTuto/Shared/NavMenu.razor b/BlazorTuto/Shared/NavMenu.razor index f1e98b8..4a4c7ee 100644 --- a/BlazorTuto/Shared/NavMenu.razor +++ b/BlazorTuto/Shared/NavMenu.razor @@ -14,21 +14,11 @@ Home - - diff --git a/README.md b/README.md index 5a527ad..0572f2e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # BlazorTuto + + +