diff --git a/BlazorTp1.sln b/BlazorTp1.sln
index 7833526..301bf8b 100644
--- a/BlazorTp1.sln
+++ b/BlazorTp1.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorTp1", "BlazorTp1\BlazorTp1.csproj", "{FEEC35E0-2A45-48AD-BBE9-854887762D8E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorTp1", "BlazorTp1\BlazorTp1.csproj", "{FEEC35E0-2A45-48AD-BBE9-854887762D8E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/BlazorTp1/BlazorTp1.csproj b/BlazorTp1/BlazorTp1.csproj
index c78c9c7..c0eacf6 100644
--- a/BlazorTp1/BlazorTp1.csproj
+++ b/BlazorTp1/BlazorTp1.csproj
@@ -6,4 +6,11 @@
enable
+
+
+
+
+
+
+
diff --git a/BlazorTp1/Models/Item.cs b/BlazorTp1/Models/Item.cs
new file mode 100644
index 0000000..e697f5a
--- /dev/null
+++ b/BlazorTp1/Models/Item.cs
@@ -0,0 +1,15 @@
+namespace BlazorTp1.Models
+{
+ public class Item
+ {
+ public int Id { get; set; }
+ public string DisplayName { get; set; }
+ public string Name { get; set; }
+ public int StackSize { get; set; }
+ public int MaxDurability { get; set; }
+ public List EnchantCategories { get; set; }
+ public List RepairWith { get; set; }
+ public DateTime CreatedDate { get; set; }
+ public DateTime? UpdatedDate { get; set; }
+ }
+}
diff --git a/BlazorTp1/Models/ItemModel.cs b/BlazorTp1/Models/ItemModel.cs
new file mode 100644
index 0000000..cf93333
--- /dev/null
+++ b/BlazorTp1/Models/ItemModel.cs
@@ -0,0 +1,37 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace BlazorTp1.Models
+{
+ public class ItemModel
+ {
+ public int Id { get; set; }
+
+ [Required]
+ [StringLength(50, ErrorMessage = "The display name must not exceed 50 characters.")]
+ public string DisplayName { get; set; }
+
+ [Required]
+ [StringLength(50, ErrorMessage = "The name must not exceed 50 characters.")]
+ [RegularExpression(@"^[a-z''-'\s]{1,40}$", ErrorMessage = "Only lowercase characters are accepted.")]
+ public string Name { get; set; }
+
+ [Required]
+ [Range(1, 64)]
+ public int StackSize { get; set; }
+
+ [Required]
+ [Range(1, 125)]
+ public int MaxDurability { get; set; }
+
+ public List EnchantCategories { get; set; }
+
+ public List RepairWith { get; set; }
+
+ [Required]
+ [Range(typeof(bool), "true", "true", ErrorMessage = "You must agree to the terms.")]
+ public bool AcceptCondition { get; set; }
+
+ [Required(ErrorMessage = "The image of the item is mandatory!")]
+ public byte[] ImageContent { get; set; }
+ }
+}
diff --git a/BlazorTp1/Pages/Add.razor b/BlazorTp1/Pages/Add.razor
new file mode 100644
index 0000000..cfbc78b
--- /dev/null
+++ b/BlazorTp1/Pages/Add.razor
@@ -0,0 +1,5 @@
+@page "/add"
+
+Add
+
+
diff --git a/BlazorTp1/Pages/Add.razor.cs b/BlazorTp1/Pages/Add.razor.cs
new file mode 100644
index 0000000..1c2cff2
--- /dev/null
+++ b/BlazorTp1/Pages/Add.razor.cs
@@ -0,0 +1,6 @@
+namespace BlazorTp1.Pages
+{
+ public partial class Add
+ {
+ }
+}
diff --git a/BlazorTp1/Pages/List.razor b/BlazorTp1/Pages/List.razor
index d81cfab..810c9d6 100644
--- a/BlazorTp1/Pages/List.razor
+++ b/BlazorTp1/Pages/List.razor
@@ -1,5 +1,34 @@
- @page "/list"
+@page "/list"
+@using BlazorTp1.Models
List
+
+
+ Ajouter
+
+
+
+
+
+
+
+
+
+ @(string.Join(", ", ((Item)context).EnchantCategories))
+
+
+
+
+ @(string.Join(", ", ((Item)context).RepairWith))
+
+
+
+
diff --git a/BlazorTp1/Pages/List.razor.cs b/BlazorTp1/Pages/List.razor.cs
index 43c398a..b41aa67 100644
--- a/BlazorTp1/Pages/List.razor.cs
+++ b/BlazorTp1/Pages/List.razor.cs
@@ -1,6 +1,60 @@
-namespace BlazorTp1.Pages
+using Microsoft.AspNetCore.Components;
+using BlazorTp1.Models;
+using Blazorise.DataGrid;
+using Blazored.LocalStorage;
+
+namespace BlazorTp1.Pages
{
public partial class List
{
+ private List- items;
+
+ private int totalItem;
+
+ [Inject]
+ public HttpClient Http { get; set; }
+
+ [Inject]
+ public ILocalStorageService LocalStorage { get; set; }
+
+ [Inject]
+ public NavigationManager NavigationManager { get; set; }
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ // Do not treat this action if is not the first render
+ if (!firstRender)
+ {
+ return;
+ }
+
+ 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 (we load the data sync for initialize the data before load the OnReadData method)
+ var originalData = Http.GetFromJsonAsync
- ($"{NavigationManager.BaseUri}fake-data.json").Result;
+ await LocalStorage.SetItemAsync("data", originalData);
+ }
+ }
+
+ private async Task OnReadData(DataGridReadDataEventArgs
- e)
+ {
+ if (e.CancellationToken.IsCancellationRequested)
+ {
+ return;
+ }
+
+ // When you use a real API, we use this follow code
+ //var response = await Http.GetJsonAsync( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" );
+ var response = (await LocalStorage.GetItemAsync
- ("data")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
+
+ if (!e.CancellationToken.IsCancellationRequested)
+ {
+ totalItem = (await LocalStorage.GetItemAsync
>("data")).Count;
+ items = new List- (response); // an actual data for the current page
+ }
+ }
}
}
diff --git a/BlazorTp1/Pages/_Layout.cshtml b/BlazorTp1/Pages/_Layout.cshtml
index 2c4ae6f..641ca97 100644
--- a/BlazorTp1/Pages/_Layout.cshtml
+++ b/BlazorTp1/Pages/_Layout.cshtml
@@ -1,4 +1,4 @@
-@using Microsoft.AspNetCore.Components.Web
+ @using Microsoft.AspNetCore.Components.Web
@namespace BlazorTp1.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@@ -28,5 +28,11 @@
+
+
+
+
+
+