From 87e6aa14ac8c5be4cac5b080c0f542d2ac3dd296 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 27 May 2020 15:12:05 +0300 Subject: When a organization is selected the sites is refreshed and added "None" value. Related Work Items: #2872 --- .../ViewModels/MainViewVM.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') 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 _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() ; + 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(); + sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); + Sites = sites; + SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); + } } } -- cgit v1.3.1 From 96bb8c83a824dfd1dbe12605a55f5549e554ea2b Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 31 May 2020 09:12:37 +0300 Subject: Changed query "give all the sites where the organization equals to the machine's organization" Related Work Items: #2872 --- .../Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') 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 d52daaea2..c4850deb8 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 @@ -615,7 +615,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels _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() ; + Sites = ActiveMachine.Organization != null ? _all_sites.Where(x => x.OrganizationGuid == ActiveMachine.OrganizationGuid).ToList() : new List() ; Sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); @@ -1004,7 +1004,7 @@ 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(); + var sites = ActiveMachine.Organization != null ? _all_sites.Where(x => x.OrganizationGuid == ActiveMachine.OrganizationGuid).ToList() : new List(); sites.Insert(0, new Site() { Name = "NONE", ID = -1 }); Sites = sites; SelectedSite = Sites.SingleOrDefault(x => x.Guid == ActiveMachine.SiteGuid); -- cgit v1.3.1