Display error message if script couldn't save. Stop success from blocking dialog close.

net8.0^2
Pat Hartl 2023-11-30 19:12:25 -06:00
parent 78168e94a5
commit e4531321b1
1 changed files with 18 additions and 9 deletions

View File

@ -111,13 +111,13 @@
public override async Task CancelAsync(ModalClosingEventArgs args) public override async Task CancelAsync(ModalClosingEventArgs args)
{ {
Editor.Dispose(); Editor.Dispose();
await base.CancelAsync(args); await base.CancelAsync(args);
} }
private async void BrowseForPath() private async void BrowseForPath()
{ {
var modalOptions = new ModalOptions() var modalOptions = new ModalOptions()
{ {
Title = "Choose Reference", Title = "Choose Reference",
@ -172,15 +172,24 @@
private async Task Save() private async Task Save()
{ {
var value = await Editor.GetValue(); try
{
var value = await Editor.GetValue();
Script.Contents = value; Script.Contents = value;
if (Script.Id == Guid.Empty) if (Script.Id == Guid.Empty)
Script = await ScriptService.Add(Script); Script = await ScriptService.Add(Script);
else else
Script = await ScriptService.Update(Script); Script = await ScriptService.Update(Script);
await MessageService.Success("Script saved!"); MessageService.Success("Script saved!");
}
catch (Exception ex)
{
MessageService.Error("Script could not be saved!");
throw ex;
}
} }
} }