Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
From this class, I'd like to modify the "MONTHLY" and "ROI" strings from the GUI using a ComboBox?

I've searched but couldn't find anything concrete.

Do you have any ideas?

What I have tried:

C#
using BasicProject.Model;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

public class BinanceApi
{
    public static async Task<List<UserRank>> 
       GetLeaderboardRank(string tradeType)
    {
        try
        {
            using (HttpClient client = new HttpClient
                  ((HttpMessageHandler)new HttpClientHandler()
            {
                UseCookies = false
            }))
            {
                string payload = JsonConvert.SerializeObject((object)new
                {
                    tradeType = tradeType,
                    isShared = true,
                    isTrader = false,
                    periodType = "MONTHLY", 
                    statisticsType = "ROI"
                });
            }
            return userRanks;
         }
    }
    catch (Exception ex)
    {
        BinanceApi.Log.Error((object) ex);
        return (List<UserRank>)null;
    }
}
Posted
Updated 6-Nov-23 1:10am
v2

1 solution

OK, there's a lot wrong in the code you posted. First, you never set the value of userRanks before you return it, so your Task is returning null. Hell, the code won't even compile because you never defined what userRanks is!

You as serializing an anonymous object to a string, payload, but then never do anything with that so the content is just destroyed when you hit the return.

There is nothing in the code you posted that calls this method, so it's impossible to guess what else your code is doing let alone what you're doing with the data that should be returned.

You also never posted any code related to your GUI, so the generic answer is going to be you have to await the GetLeaderboardRank method to get its return value, then set the data in whatever controls you have in your GUI.

You don't even say what type of app your GUI is! Windows Forms, WPF, ASP.NET MVC, Blazor, Razor, ???
 
Share this answer
 
Comments
Maciej Los 5-Nov-23 13:23pm    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900