Main window.xaml
<TextBox Text="{Binding SummonerNameDTO}"/>
<Button Click="Button_Click">Find</Button>
Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
var SummonerName = _summonerDTOService.GetSummonerDTO(_viewModel.SummonerNameDTO).Id;
}
SummonerDTOResponse GetSummonerDTO ()
public class SummonerDTOService
{
RestClient client = new RestClient("https://euw1.api.riotgames.com/lol/summoner/v4/summoners/");
public SummonerDTOResponse GetSummonerDTO(string SummonerName)
{
var request = new RestRequest("by-name/{summonerName}")
.AddParameter("summonerName", SummonerName, ParameterType.UrlSegment)
.AddParameter("api_key", "api-key");
var response = client.Execute<SummonerDTOResponse>(request);
if (!response.IsSuccessful)
{
return default;
}
return response.Data;
}
}
public class SummonerDTOResponse
{
public string Id { get; set; }
}
}
Я хочу отправить из значения TextBlock в summonerDTOResponse GetSummonerDTO ().