diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-05-27 15:12:05 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-05-27 15:12:05 +0300 |
| commit | 87e6aa14ac8c5be4cac5b080c0f542d2ac3dd296 (patch) | |
| tree | 762cdb240f8c405d170408ebf63391420474cdd1 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner | |
| parent | 7102ed21905bc52c6aee506e919992ce1f98f641 (diff) | |
| download | Tango-87e6aa14ac8c5be4cac5b080c0f542d2ac3dd296.tar.gz Tango-87e6aa14ac8c5be4cac5b080c0f542d2ac3dd296.zip | |
When a organization is selected the sites is refreshed and added "None" value.
Related Work Items: #2872
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index ed93b4308..d52daaea2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -39,6 +39,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private ActionTimer _machines_action_timer; private ActionTimer _dispensers_action_timer; private MachineDTO _machineBeforeSave; + private List<Site> _all_sites; #region Properties @@ -609,11 +610,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } } + ActiveMachine.OrganizationChanged -= ActiveMachine_OrganizationChanged; + ActiveMachine.OrganizationChanged += ActiveMachine_OrganizationChanged; - var sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); - sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + _all_sites = await ActiveMachineAdapter.Context.Sites.ToListAsync(); + + Sites = ActiveMachine.Organization != null ? _all_sites.Where(x => ActiveMachine.Organization.Sites.All(y => y.OrganizationGuid == x.OrganizationGuid)).ToList() : new List<Site>() ; + Sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); - Sites = sites; SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, ActiveMachine, _activeMachineAdapter.Context) @@ -651,7 +655,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } } - + private async void Configuration_HardwareVersionChanged(object sender, HardwareVersion e) { var version = ActiveMachine.Configuration.HardwareVersion; @@ -997,5 +1001,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels }); } } + + private void ActiveMachine_OrganizationChanged(object sender, Organization e) + { + var sites = ActiveMachine.Organization != null ? _all_sites.Where(x => ActiveMachine.Organization.Sites.All(y => y.OrganizationGuid == x.OrganizationGuid)).ToList() : new List<Site>(); + sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + Sites = sites; + SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); + } } } |
