diff --git a/TutoBlazer/App.razor b/TutoBlazer/App.razor
index 623580d..54966a1 100644
--- a/TutoBlazer/App.razor
+++ b/TutoBlazer/App.razor
@@ -1,12 +1,14 @@
-
-
-
-
-
-
- Not found
-
- Sorry, there's nothing at this address.
-
-
-
+
+
+
+
+
+
+
+ Not found
+
+ Sorry, there's nothing at this address.
+
+
+
+
diff --git a/TutoBlazer/Controllers/CultureController.cs b/TutoBlazer/Controllers/CultureController.cs
new file mode 100644
index 0000000..6c790cd
--- /dev/null
+++ b/TutoBlazer/Controllers/CultureController.cs
@@ -0,0 +1,36 @@
+using Microsoft.AspNetCore.Localization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace TutoBlazer.Controllers
+{
+
+
+ ///
+ /// The culture controller.
+ ///
+ [Route("[controller]/[action]")]
+ public class CultureController : Controller
+ {
+ ///
+ /// Sets the culture.
+ ///
+ /// The culture.
+ /// The redirect URI.
+ ///
+ /// The action result.
+ ///
+ public IActionResult SetCulture(string culture, string redirectUri)
+ {
+ if (culture != null)
+ {
+ // Define a cookie with the selected culture
+ this.HttpContext.Response.Cookies.Append(
+ CookieRequestCultureProvider.DefaultCookieName,
+ CookieRequestCultureProvider.MakeCookieValue(
+ new RequestCulture(culture)));
+ }
+
+ return this.LocalRedirect(redirectUri);
+ }
+ }
+}
diff --git a/TutoBlazer/Modals/DeleteConfirmation.razor b/TutoBlazer/Modals/DeleteConfirmation.razor
new file mode 100644
index 0000000..32baae9
--- /dev/null
+++ b/TutoBlazer/Modals/DeleteConfirmation.razor
@@ -0,0 +1,10 @@
+
diff --git a/TutoBlazer/Modals/DeleteConfirmation.razor.cs b/TutoBlazer/Modals/DeleteConfirmation.razor.cs
new file mode 100644
index 0000000..5752b94
--- /dev/null
+++ b/TutoBlazer/Modals/DeleteConfirmation.razor.cs
@@ -0,0 +1,37 @@
+using Blazored.Modal.Services;
+using Blazored.Modal;
+using Microsoft.AspNetCore.Components;
+using TutoBlazer.Models;
+
+namespace TutoBlazer.Modals
+{
+ public partial class DeleteConfirmation
+ {
+ [CascadingParameter]
+ public BlazoredModalInstance ModalInstance { get; set; }
+
+ [Inject]
+ public IDataService DataService { get; set; }
+
+ [Parameter]
+ public int Id { get; set; }
+
+ private Item item = new Item();
+
+ protected override async Task OnInitializedAsync()
+ {
+ // Get the item
+ item = await DataService.GetById(Id);
+ }
+
+ void ConfirmDelete()
+ {
+ ModalInstance.CloseAsync(ModalResult.Ok(true));
+ }
+
+ void Cancel()
+ {
+ ModalInstance.CancelAsync();
+ }
+ }
+}
diff --git a/TutoBlazer/Pages/Index.razor b/TutoBlazer/Pages/Index.razor
index b1a9fbd..b221db1 100644
--- a/TutoBlazer/Pages/Index.razor
+++ b/TutoBlazer/Pages/Index.razor
@@ -1,4 +1,5 @@
-@page "/"
+@using System.Globalization
+@page "/"
Index
@@ -6,4 +7,8 @@
Welcome to your new app.
+
+ CurrentCulture: @CultureInfo.CurrentCulture
+
+
diff --git a/TutoBlazer/Pages/List.razor b/TutoBlazer/Pages/List.razor
index 98cba6e..59162a9 100644
--- a/TutoBlazer/Pages/List.razor
+++ b/TutoBlazer/Pages/List.razor
@@ -1,7 +1,8 @@
@page "/list"
@using Models
-List
+
+@Localizer["Title"]
diff --git a/TutoBlazer/Pages/List.razor.cs b/TutoBlazer/Pages/List.razor.cs
index bd4a147..51f22e9 100644
--- a/TutoBlazer/Pages/List.razor.cs
+++ b/TutoBlazer/Pages/List.razor.cs
@@ -1,6 +1,10 @@
using Blazored.LocalStorage;
+using Blazored.Modal;
+using Blazored.Modal.Services;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Localization;
+using TutoBlazer.Modals;
using TutoBlazer.Models;
namespace TutoBlazer.Pages
@@ -11,12 +15,21 @@ namespace TutoBlazer.Pages
private int totalItem;
+ [Inject]
+ public IStringLocalizer Localizer { get; set; }
+
[Inject]
public IDataService DataService { get; set; }
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
+ [Inject]
+ public NavigationManager NavigationManager { get; set; }
+
+ [CascadingParameter]
+ public IModalService Modal { get; set; }
+
private async Task OnReadData(DataGridReadDataEventArgs- e)
{
if (e.CancellationToken.IsCancellationRequested)
@@ -31,9 +44,23 @@ namespace TutoBlazer.Pages
}
}
- private void OnDelete(int id)
+ private async void OnDelete(int id)
{
+ var parameters = new ModalParameters();
+ parameters.Add(nameof(Item.Id), id);
+
+ var modal = Modal.Show("Delete Confirmation", parameters);
+ var result = await modal.Result;
+
+ if (result.Cancelled)
+ {
+ return;
+ }
+
+ await DataService.Delete(id);
+ // Reload the page
+ NavigationManager.NavigateTo("list", true);
}
}
}
diff --git a/TutoBlazer/Pages/_Layout.cshtml b/TutoBlazer/Pages/_Layout.cshtml
index 3577ddf..33c480f 100644
--- a/TutoBlazer/Pages/_Layout.cshtml
+++ b/TutoBlazer/Pages/_Layout.cshtml
@@ -33,5 +33,7 @@
+
+