Skip to content

Commit 622354c

Browse files
committed
Refactor image deletion to use confirmation dialog helper
Simplified the DeleteImage method by replacing manual dialog creation and result handling with DialogServiceHelper .ShowConfirmationDialogAsync. This centralizes confirmation logic and improves code readability and maintainability.
1 parent 1fe957e commit 622354c

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/Server.UI/Pages/Products/Components/ProductFormDialog.razor

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,14 @@
136136
{
137137
if (Model.Pictures != null)
138138
{
139-
var parameters = new DialogParameters<ConfirmationDialog>
140-
{
141-
{ x => x.ContentText, $"{L["Are you sure you want to erase this image?"]}" }
142-
};
143-
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall, FullWidth = true };
144-
var dialog = await DialogService.ShowAsync<ConfirmationDialog>($"{L["Erase imatge"]}", parameters, options);
145-
var state = await dialog.Result;
146-
147-
if (state is not null && !state.Canceled)
148-
{
149-
Model.Pictures.Remove(picture);
150-
}
139+
await DialogServiceHelper.ShowConfirmationDialogAsync(
140+
$"{L["Erase imatge"]}",
141+
$"{L["Are you sure you want to erase this image?"]}",
142+
async () =>
143+
{
144+
Model.Pictures.Remove(picture);
145+
});
146+
151147
}
152148
}
153149

0 commit comments

Comments
 (0)