示例#1
0
        private void OnRefreshConnections(RefreshChannelListEventArgument obj)
        {
            Channels = new ObservableCollection <MessageDeliveryChannelModel>(messageDeliveryChannelRepository.GetAll());
            var selectedId = obj.SelectedChannelId;

            if (obj.SelectedChannelId == Guid.Empty)
            {
                var firstConnection = Channels.FirstOrDefault();
                selectedId = firstConnection?.Id ?? Guid.Empty;
            }
            if (selectedId != Guid.Empty)
            {
                eventAggregator.GetEvent <SelectChannelEvent>().Publish(new SelectChannelEventArgument
                {
                    ChannelId = selectedId
                });
            }
        }
示例#2
0
        public UCMessageDeliveryChannelListViewViewModel(
            MessageDeliveryChannelRepository messageDeliveryChannelRepository,
            IEventAggregator eventAggregator)
        {
            this.messageDeliveryChannelRepository = messageDeliveryChannelRepository;
            this.eventAggregator = eventAggregator;
            Channels             = new ObservableCollection <MessageDeliveryChannelModel>(messageDeliveryChannelRepository.GetAll());
            eventAggregator.GetEvent <RefreshChannelListEvent>().Subscribe(OnRefreshConnections);
            var firstConection = Channels.FirstOrDefault();

            if (firstConection != null)
            {
                eventAggregator.GetEvent <SelectChannelEvent>().Publish(new SelectChannelEventArgument
                {
                    ChannelId = firstConection.Id
                });
            }
        }