RepairWith { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
+ public string ImageBase64 { get; set; }
}
}
diff --git a/Blazor/Blazor/Models/ItemModel.cs b/Blazor/Blazor/Models/ItemModel.cs
index da86696..21bc32b 100644
--- a/Blazor/Blazor/Models/ItemModel.cs
+++ b/Blazor/Blazor/Models/ItemModel.cs
@@ -33,5 +33,6 @@ namespace Blazor.Models
[Required(ErrorMessage = "The image of the item is mandatory!")]
public byte[] ImageContent { get; set; }
+ public string ImageBase64 { get; set; }
}
}
diff --git a/Blazor/Blazor/Pages/Edit.razor b/Blazor/Blazor/Pages/Edit.razor
index 57cedae..3f92e5a 100644
--- a/Blazor/Blazor/Pages/Edit.razor
+++ b/Blazor/Blazor/Pages/Edit.razor
@@ -55,14 +55,7 @@
diff --git a/Blazor/Blazor/Pages/Edit.razor.cs b/Blazor/Blazor/Pages/Edit.razor.cs
index 442d2b0..0229107 100644
--- a/Blazor/Blazor/Pages/Edit.razor.cs
+++ b/Blazor/Blazor/Pages/Edit.razor.cs
@@ -45,11 +45,6 @@ namespace Blazor.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/Blazor/Blazor/Pages/Index.razor b/Blazor/Blazor/Pages/Index.razor
index 3aba0f3..6765355 100644
--- a/Blazor/Blazor/Pages/Index.razor
+++ b/Blazor/Blazor/Pages/Index.razor
@@ -1,31 +1,5 @@
@page "/"
-@using System.Globalization
-@using Blazor.Components
-
-
-Index
-
-
Hello, world!
-
-Welcome to your new app.
-
-
-
-
- CurrentCulture: @CultureInfo.CurrentCulture
-
-
-
-
-
-
-
-
-
-
@cakeContext.Name
-
$ @cakeContext.Cost
-
-
-
+@using Blazor.Components;
+
+
+
diff --git a/Blazor/Blazor/Pages/Index.razor.cs b/Blazor/Blazor/Pages/Index.razor.cs
index be574ee..0a77a38 100644
--- a/Blazor/Blazor/Pages/Index.razor.cs
+++ b/Blazor/Blazor/Pages/Index.razor.cs
@@ -1,14 +1,32 @@
-using Blazor.Models;
+using Blazor.Components;
+using Blazor.Models;
+using Blazor.Services;
+using Microsoft.AspNetCore.Components;
namespace Blazor.Pages
{
public partial class Index
{
- private Cake CakeItem = new Cake
+ [Inject]
+ public IDataService DataService { get; set; }
+
+ public List- Items { get; set; } = new List
- ();
+
+ private List Recipes { get; set; } = new List();
+
+ protected override async Task OnAfterRenderAsync(bool firstRender)
{
- Id = 1,
- Name = "Black Forest",
- Cost = 50
- };
+ base.OnAfterRenderAsync(firstRender);
+
+ if (!firstRender)
+ {
+ return;
+ }
+
+ Items = await DataService.List(0, await DataService.Count());
+ Recipes = await DataService.GetRecipes();
+
+ StateHasChanged();
+ }
}
}
diff --git a/Blazor/Blazor/Pages/List.razor b/Blazor/Blazor/Pages/List.razor
index 2f954fc..8a55786 100644
--- a/Blazor/Blazor/Pages/List.razor
+++ b/Blazor/Blazor/Pages/List.razor
@@ -21,17 +21,17 @@
Responsive>
-
- @if (File.Exists($"{WebHostEnvironment.WebRootPath}/images/{context.Name}.png"))
- {
-
- }
- else
- {
-
- }
-
-
+
+ @if (!string.IsNullOrWhiteSpace(context.ImageBase64))
+ {
+
+ }
+ else
+ {
+
+ }
+
+
diff --git a/Blazor/Blazor/Pages/_Layout.cshtml b/Blazor/Blazor/Pages/_Layout.cshtml
index 839e817..f627359 100644
--- a/Blazor/Blazor/Pages/_Layout.cshtml
+++ b/Blazor/Blazor/Pages/_Layout.cshtml
@@ -33,6 +33,7 @@
+