/// <summary> /// Pobiera ulubione gatunki anime /// </summary> /// <param name="user"></param> /// <returns></returns> public string GetfavouredGenres(string user) { string str = ""; string query = @" query($userName: String) { # Define which variables will be used in the query (id) User(name: $userName) { stats { favouredGenresOverview { genre amount } } } } "; Dictionary <string, object> variables = new Dictionary <string, object>() { { "userName", user } }; GraphQlQueryResponse result = obj.MakeRequestAsync(query, variables).Result; dynamic gpl = result.GetData("User"); foreach (var item in gpl.stats.favouredGenresOverview) { str = str + "Genre: " + item.genre.ToString() + " Amount: " + item.amount.ToString() + "\n"; } return(str); }
/// <summary> /// Tworzy stringa z listą nazw anime /// </summary> /// <param name="result"></param> /// <returns></returns> private string MakeString(GraphQlQueryResponse result) { string userWatchAnimeList = ""; dynamic gpl = result.GetData("MediaListCollection"); if (gpl.lists.Count == 0) { return("The list is empty"); } foreach (var item in gpl.lists[0].entries) { userWatchAnimeList = userWatchAnimeList + item.media.title.romaji.ToString() + '\n'; } return(userWatchAnimeList); }