private async Task <bool> TryConnectionAsync(string uri) { var mediaContainer = await _connectionHelper.MakeRequestAsync <MediaContainer>(Method.Get, uri, "/", Username, Password); if (mediaContainer == null) { return(false); } if (MediaContainer == null) { MediaContainer = mediaContainer; await RefreshSessionAsync(); } else { if (MediaContainer.UpdateFrom(mediaContainer)) { RaisePropertyChanged(() => MediaContainer); } await RefreshSessionAsync(); } return(true); }
private async Task <bool> TryConnectionAsync(string uri) { var response = await MakePlexRequestAsync <MediaContainer, string>(uri, "/"); if (response == null || response.ResponseObject == null) { if (response != null && response.StatusCode == 401) { ConnectionStatus = ConnectionStatus.NotAuthorized; } else { ConnectionStatus = ConnectionStatus.NotConnected; } MediaContainer = null; return(false); } ConnectionUri = uri; if (MediaContainer == null) { MediaContainer = response.ResponseObject; await RefreshSessionAsync(); } else { if (response.ResponseObject == null) { ClearMediaContainer(); } else { if (MediaContainer.UpdateFrom(response.ResponseObject)) { RaisePropertyChanged(() => MediaContainer); } await RefreshSessionAsync(); } } ConnectionStatus = ConnectionStatus.Connected; return(true); }