aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Modules/Tango.FSE.MachineConfiguration/ViewModels/ConfigurationViewVM.cs
blob: 1540a4e6741ca505a8c354c67141128bfdb9d278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.FSE.Common;
using Tango.FSE.Common.AutoComplete;
using Tango.FSE.MachineConfiguration.Messages;

namespace Tango.FSE.MachineConfiguration.ViewModels
{
    public class ConfigurationViewVM : FSEViewModel
    {
        private Machine _machine;
        public Machine Machine
        {
            get { return _machine; }
            set { _machine = value; RaisePropertyChangedAuto(); }
        }

        private List<Organization> _organizations;
        public List<Organization> Organizations
        {
            get { return _organizations; }
            set { _organizations = value; RaisePropertyChangedAuto(); }
        }

        public ConfigurationViewVM()
        {
            RegisterForMessage<MachineLoadedMessage>(HandleMachineLoadedMessage);
        }

        private async void HandleMachineLoadedMessage(MachineLoadedMessage msg)
        {
            using (NotificationProvider.PushTaskItem("Loading configuration options..."))
            {
                Machine = msg.Machine;
                Organizations = await Services.OrganizationsService.GetCurrentUserOrganizations();
                Machine.Organization = Organizations.SingleOrDefault(x => x.Guid == Machine.OrganizationGuid);
            }
        }
    }
}