AccountingNext/Schaad.Accounting.UI/Components/Pages/Classes.razor.cs
Claudio Schaad 69d3122243 PR U-7: success toasts after mutations
Add IToastService.ShowToast(ToastIntent.Success, ...) after each
successful save/delete across Accounts, BookingRules, BookingTexts,
Classes, and Transactions. Toasts fire after the list re-fetch so
the confirmation is visible even if the edited item paginated out of
view.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-04 09:51:38 +02:00

78 lines
2.7 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Interfaces;
using Schaad.Accounting.Models;
using Schaad.Accounting.UI.Components.Pages.Dialogs;
namespace Schaad.Accounting.UI.Components.Pages;
public partial class Classes : ComponentBase
{
[Inject]
private ISubclassRepository subclassRepository { get; set; } = null!;
[Inject]
private IDialogService dialogService { get; set; } = null!;
[Inject]
private IToastService toastService { get; set; } = null!;
private IQueryable<SubClass>? subclassQueryable;
protected override async Task OnInitializedAsync()
{
subclassQueryable = (await subclassRepository.GetSubClassListAsync()).AsQueryable();
await base.OnInitializedAsync();
}
private async Task AddAsync()
{
var data = new SubClass();
var dialog = await dialogService.ShowDialogAsync<ClassDialog>(data, new DialogParameters()
{
Height = "500px",
Title = "Klasse",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
subclassQueryable = (await subclassRepository.GetSubClassListAsync()).AsQueryable();
toastService.ShowToast(ToastIntent.Success, "Klasse gespeichert", 3000);
}
}
private async Task EditAsync(string id)
{
var data = await subclassRepository.GetSubClassAsync(id);
var dialog = await dialogService.ShowDialogAsync<ClassDialog>(data, new DialogParameters()
{
Height = "500px",
Title = "Klasse",
PreventDismissOnOverlayClick = true,
PreventScroll = true,
});
var result = await dialog.Result;
if (!result.Cancelled && result.Data != null)
{
subclassQueryable = (await subclassRepository.GetSubClassListAsync()).AsQueryable();
toastService.ShowToast(ToastIntent.Success, "Klasse gespeichert", 3000);
}
}
private async Task DeleteAsync(string id)
{
var subclass = await subclassRepository.GetSubClassAsync(id);
var dialog = await dialogService.ShowConfirmationAsync($"Klasse '{subclass.Name}' wirklich löschen?", "Ja", "Nein", "Klasse löschen");
var result = await dialog.Result;
if (!result.Cancelled)
{
await subclassRepository.DeleteSubClassAsync(id);
subclassQueryable = (await subclassRepository.GetSubClassListAsync()).AsQueryable();
toastService.ShowToast(ToastIntent.Success, "Klasse gelöscht", 3000);
}
}
}