public async void fetchProfile()
        {
            try
            {
                var response = await ServerService.instance.client.GetAsync(Constants.SERVER_PATH + Constants.USER_INFO_PATH + ServerService.instance.username);

                if (response.IsSuccessStatusCode)
                {
                    string responseString = await response.Content.ReadAsStringAsync();

                    var data = JsonConvert.DeserializeObject <User>(responseString);
                    ServerService.instance.user = data;
                    Firstname   = ServerService.instance.user.firstName;
                    Lastname    = ServerService.instance.user.lastName;
                    Connections = ServerService.instance.user.connections;
                    Stats       = ServerService.instance.user.stats;
                    Games       = ServerService.instance.user.games;
                }
            }
            catch (Exception)
            {
                App.Current.Dispatcher.Invoke(delegate
                {
                    MessageBoxDisplayer.ShowMessageBox("failed to retrieve stats");
                });
            }
        }
 private void ShowMessageBox(string message)
 {
     App.Current.Dispatcher.Invoke(delegate
     {
         MessageBoxDisplayer.ShowMessageBox(message);
     });
 }
        public ConnectionViewModel(
            ConnectionManager connectionManager,
            SerialPortsProvider serialPortsProvider,
            SerialConnectionFactory serialPortConnectionFactory,
            SerialBoundRatesProvider serialPortBoundRatesProvider,
            MessageBoxDisplayer messageBoxDisplayer,
            UiDispatcherProvider uiDispatcherProvider)
        {
            this.SerialPorts = serialPortsProvider.GetPortNames();
            this.BoundRates  = serialPortBoundRatesProvider.GetBoundRates();

            this.connectionManager           = connectionManager;
            this.serialPortConnectionFactory = serialPortConnectionFactory;
            this.messageBoxDisplayer         = messageBoxDisplayer;
            this.uiDispatcherProvider        = uiDispatcherProvider;

            this.ConnectCommand    = new RelayCommand(this.Connect, this.CanConnect);
            this.DisconnectCommand = new RelayCommand(this.Disconnect, this.CanDisconnect);

            this.SelectedSerialPort = this.SerialPorts.FirstOrDefault();
            this.SelectedBoundRate  = this.BoundRates.First();
        }