diff --git a/Wave/Components/Pages/ManageCategories.razor b/Wave/Components/Pages/ManageCategories.razor index 8729c90..482ae04 100644 --- a/Wave/Components/Pages/ManageCategories.razor +++ b/Wave/Components/Pages/ManageCategories.razor @@ -20,6 +20,12 @@
--> +@if (!string.IsNullOrWhiteSpace(Message)) { +
+ @Message +
+} +
@@ -58,23 +64,30 @@ private InputModel Model { get; set; } = new(); private List Categories { get; set; } = new(); + private string Message { get; set; } = string.Empty; + protected override async Task OnInitializedAsync() { await using var context = await ContextFactory.CreateDbContextAsync(); Categories = await context.Set().OrderBy(c => c.Color).ToListAsync(); } private async Task AddCategory_OnValidSubmit() { - await using var context = await ContextFactory.CreateDbContextAsync(); + try { + await using var context = await ContextFactory.CreateDbContextAsync(); - var category = new Category { - Name = Model.Name.Trim(), - Color = Model.Color - }; + var category = new Category { + Name = Model.Name.Trim(), + Color = Model.Color + }; - await context.AddAsync(category); - await context.SaveChangesAsync(); - Categories.Add(category); - Model = new(); + await context.AddAsync(category); + await context.SaveChangesAsync(); + Categories.Add(category); + Model = new(); + Message = Localizer["Category_Success"]; + } catch { + Message = Localizer["Category_Error"]; + } } private sealed class InputModel { diff --git a/Wave/Resources/Components/Pages/ManageCategories.de-DE.resx b/Wave/Resources/Components/Pages/ManageCategories.de-DE.resx index 1d3e3f7..7241925 100644 --- a/Wave/Resources/Components/Pages/ManageCategories.de-DE.resx +++ b/Wave/Resources/Components/Pages/ManageCategories.de-DE.resx @@ -131,4 +131,10 @@ Sekundär + + Kategorie hinzugefügt. + + + Fehler beim hinzufügen der Kategorie. Kategorien müssen einzigartis sein, ungeachtet Groß-/Kleinschreibung oder Akzenten. + \ No newline at end of file diff --git a/Wave/Resources/Components/Pages/ManageCategories.resx b/Wave/Resources/Components/Pages/ManageCategories.resx index e48f7ca..94e1bf4 100644 --- a/Wave/Resources/Components/Pages/ManageCategories.resx +++ b/Wave/Resources/Components/Pages/ManageCategories.resx @@ -131,4 +131,10 @@ Primary + + Category added. + + + Failed to add category. Categories need to be unique, ignoring case and accents. + \ No newline at end of file