public async Task <List <Flashcard> > GetFlashcards(string deckId, CancellationTokenSource cts = null) { if (!string.IsNullOrEmpty(deckId)) { string re1 = "(........)-(....)-(....)-(....)-(............)"; Regex r1 = new Regex(re1, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m1 = r1.Match(deckId); string url = "http://78.133.154.70:2000/decks/" + deckId + "/flashcards"; if (!string.IsNullOrEmpty(url) && m1.Success) { string webPageSource = "[" + "{" + "\"question\": \"Sample question\", " + "\"answer\": \"Sample answer\"," + "\"isHidden\": false," + "\"id\": \"12345678-9012-3456-7890-123456789012\"" + "}," + "{" + "\"question\": \"Second question\", " + "\"answer\": \"Second answer\"," + "\"isHidden\": true," + "\"id\": \"12345678-9012-3456-7890-123456789012\"" + "}" + "]"; try { var result = _deserializeJsonService.GetObjectFromJson <List <Flashcard> >(webPageSource); return(result); } catch (Exception) { return(null); } } else { Exception exception = null; if (true) { throw exception; } } } return(null); }
public async Task <ScienceDirectSearchQuery> GetSearchQueryScienceDirect(string query, CancellationTokenSource cts = null) { try { string url = String.Format(_resources["SearchQueryScienceDirect"].ToString(), query, _currentScienceDirectAndScopusApiKey); string webPageSource = await GetWebPageSource(url, cts); return(_deserializeJsonService.GetObjectFromJson <ScienceDirectSearchQuery>(webPageSource)); } catch (TaskCanceledException) { throw; } catch (Exception) { Messenger.Default.Send(new ExceptionToSettingsMessage { Exception = ViewModelLocator.Instance.Settings, Source = "Science Direct", }); return(null); } }
public async Task <List <Flashcard> > GetFlashcards(string deckId, CancellationTokenSource cts = null) { try { string url = String.Format(_resources["FlashcardGetAllUrl"].ToString(), deckId); string webPageSource = await GetWebPageSource(url, cts); return(_deserializeJsonService.GetObjectFromJson <List <Flashcard> >(webPageSource)); } catch (TaskCanceledException ex) { throw ex; } catch (Exception) { return(null); } }