private async void ExecuteConnect() { StartLoading(); IsConnecting = true; try { if (!await DataRepository.OpenRepository(ClientUtil.CreateConnectionString(ConnectionAddress, uint.Parse(ConnectionPort)))) { IsConnecting = false; StopLoading(); DialogInformationViewModel.OpenDialog(DialogIdentifier1, "Failed to open the data repository!"); return; } IsConnected = true; Clients = new ObservableCollection <IClient>(await DataRepository.GetAllClients()); Orders = new ObservableCollection <IOrder>(await DataRepository.GetAllOrders()); Products = new ObservableCollection <IProduct>(await DataRepository.GetAllProducts()); OrderSentUnsubscriber = DataRepository.Subscribe((IObserver <OrderSent>) this); ClientUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IClient> >) this); ProductUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IProduct> >) this); OrderUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IOrder> >) this); } catch (Exception e) { IsConnected = false; DialogInformationViewModel.OpenDialog(DialogIdentifier1, $"Connection initialization failed!\n{e}"); } IsConnecting = false; StopLoading(); }