diff --git a/VECTO3GUI/ViewModel/Impl/AbstractBusJobViewModel.cs b/VECTO3GUI/ViewModel/Impl/AbstractBusJobViewModel.cs index 37c5556ff67357e1263700f690d733ee443e4d07..e1e0968684c9650ebcc26389ea38f75a6b4a96b4 100644 --- a/VECTO3GUI/ViewModel/Impl/AbstractBusJobViewModel.cs +++ b/VECTO3GUI/ViewModel/Impl/AbstractBusJobViewModel.cs @@ -126,14 +126,14 @@ namespace VECTO3GUI.ViewModel.Impl _editJob = true; } - private void Init(IKernel kernel, JobType jobType) + private void Init(IKernel kernel, JobType jobType) { SecondLabelText = $"Select {JobFileType.CompletedBusFile.GetLable()}"; Settings = new SettingsModel(); SetFileTypes(jobType); Kernel = kernel; } - + private void SetFileTypes(JobType jobType) { JobType = jobType; @@ -180,7 +180,7 @@ namespace VECTO3GUI.ViewModel.Impl { SecondFilePath = OpenFileSelector(jobFileType, nameof(SecondFilePath)); } - + public ICommand CancelCommand { get { return _cancelCommand ?? (_cancelCommand = new RelayCommand<Window>(DoCancelCommand)); } @@ -201,9 +201,9 @@ namespace VECTO3GUI.ViewModel.Impl private void DoSaveCommand(Window window) { window.DialogResult = true; - if (!_editJob) + if (!_editJob) SaveJob(window); - else + else UpdateJobData(); } @@ -212,19 +212,21 @@ namespace VECTO3GUI.ViewModel.Impl private void SaveJob(Window window) { var jobFilePath = FileDialogHelper.SaveJobFileToDialog(Settings.XmlFilePathFolder); - if (jobFilePath != null) { - - var job = new JobEntry { - JobEntryFilePath = jobFilePath, - FirstFilePath = FirstFilePath, - SecondFilePath = SecondFilePath, - JobType = JobType - }; - - SerializeHelper.SerializeToFile(jobFilePath, job); - SavedJobEntry = job; - DoCancelCommand(window); - } + if (jobFilePath == null) + return; + + var job = new JobEntry + { + JobEntryFilePath = jobFilePath, + FirstFilePath = FirstFilePath, + SecondFilePath = SecondFilePath, + JobType = JobType + }; + + SerializeHelper.SerializeToFile(jobFilePath, job); + SavedJobEntry = job; + DoCancelCommand(window); + } private void UpdateJobData() @@ -232,7 +234,7 @@ namespace VECTO3GUI.ViewModel.Impl SavedJobEntry.FirstFilePath = FirstFilePath; SavedJobEntry.SecondFilePath = SecondFilePath; } - + private string OpenFileSelector(JobFileType jobFileType, string textPropertyName) { diff --git a/VECTO3GUI/ViewModel/Impl/CompleteVehicleBusJobViewModel.cs b/VECTO3GUI/ViewModel/Impl/CompleteVehicleBusJobViewModel.cs index d414dcacfcf0548f5b2f56dd2e19855c1b766db4..ccae3e62319f5e41e4c59ea231d4bb99e3da3aaa 100644 --- a/VECTO3GUI/ViewModel/Impl/CompleteVehicleBusJobViewModel.cs +++ b/VECTO3GUI/ViewModel/Impl/CompleteVehicleBusJobViewModel.cs @@ -94,6 +94,8 @@ namespace VECTO3GUI.ViewModel.Impl protected override void DoSaveToJob(Window window) { var filePath = FileDialogHelper.SaveXmlFileToDialog(SettingsModel.XmlFilePathFolder); + if(filePath == null) + return; SetCurrentDataToSave(); var xDocument = _xmlCompletedBus.GenerateCompletedBusDocument(CompleteVehicleBusData);