From b2d8f58efc111777678513f879827c2cea4fc6a6 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 23 May 2021 12:04:55 +0300 Subject: Fixed issue with RML creation name validation on MS. --- .../Tango.MachineStudio.RML/ViewModels/MainViewVM.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 272316b02..2a1bc1bbb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -276,7 +276,7 @@ namespace Tango.MachineStudio.RML.ViewModels public override void OnApplicationReady() { - + } private async Task LoadRmls() @@ -490,10 +490,13 @@ namespace Tango.MachineStudio.RML.ViewModels if (!String.IsNullOrWhiteSpace(name)) { - if (Rmls.ToList().Exists(x => x.Name == name)) + using (ObservablesContext db = ObservablesContext.CreateDefault()) { - _notification.ShowError("The specified RML name already exists. Please select a different name."); - return; + if (await db.Rmls.AnyAsync(x => x.Name == name)) + { + _notification.ShowError("The specified RML name already exists. Please select a different name."); + return; + } } using (_notification.PushTaskItem("Creating new RML...")) @@ -638,6 +641,13 @@ namespace Tango.MachineStudio.RML.ViewModels using (var context = ObservablesContext.CreateDefault()) { + if (await context.Rmls.AnyAsync(x => x.Name == name)) + { + _notification.ShowError("The specified RML name already exists. Please select a different name."); + IsFree = true; + return; + } + var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().WithSpools().BuildAsync(); Rml cloned = new Rml(); -- cgit v1.3.1