private void OnRefreshConnections(RefreshConnectionListEventArgument obj) { Connections = new ObservableCollection <ConnectionModel>(connectionRepository.GetAll()); var selectedId = obj.SelectedConnectionId; if (string.IsNullOrWhiteSpace(obj.SelectedConnectionId)) { var firstConnection = Connections.FirstOrDefault(); selectedId = firstConnection?.Id.ToString(); } if (!string.IsNullOrWhiteSpace(selectedId)) { eventAggregator.GetEvent <SelectConnectionEvent>().Publish(new SelectConnectionEventArgument { ConnectionId = selectedId }); } }
public UCConnectionListViewViewModel( ConnectionRepository connectionRepository, IEventAggregator eventAggregator) { this.connectionRepository = connectionRepository; this.eventAggregator = eventAggregator; Connections = new ObservableCollection <ConnectionModel>(connectionRepository.GetAll()); eventAggregator.GetEvent <RefreshConnectionListEvent>().Subscribe(OnRefreshConnections); var firstConection = Connections.FirstOrDefault(); if (firstConection != null) { eventAggregator.GetEvent <SelectConnectionEvent>().Publish(new SelectConnectionEventArgument { ConnectionId = firstConection.Id.ToString() }); } }
public IActionResult GetAll() { var connections = _connectionRepository.GetAll <ConnectionModel>(); var options = _connectionRepository.LoadOptions(connections.Select(c => c.Id.ToString())); return(Ok(connections.Select(c => { var jConnection = JObject.FromObject(c, serializer); var provider = _providers.FirstOrDefault(p => p.Id == c.ProviderId); var cOptions = options.Where(o => o.EntityId == c.Id.ToString() && o.EntityType == EntityType.Connection); var optionItems = new List <OptionItem>(); foreach (var po in provider.Options) { var o = cOptions.FirstOrDefault(oo => oo.Key == po.Name); if (o != null) { po.Value = o.Value; } optionItems.Add(po); } jConnection.Add("options", JArray.FromObject(optionItems, serializer)); return jConnection; }))); }
public List <connection> GetListConnect() { return(ConnectionRepository.GetAll().ToList()); }