I am calling a methodgetaddress();
inside viewmodel for getting address information from API. But while debugging, execution returns at var response = await client.PostAsync(base_url + "api_delivery_details", formcontent).ConfigureAwait(false);
to the calling method getaddress()
but executes the remaining portion later.so getting null result. How to execute all from first time?
public async void Get_branch_products()
{
RestClient restClient = new RestClient();
getaddresses(); //this is the calling method
long delivery_fee1 = long.Parse(delivery_fee);
GrandTotal = Total + (Total * Tax) / 100 + delivery_fee1 ;
OnPropertyChanged("GrandTotal");
tax_amt = (Total * Tax) / 100;
OnPropertyChanged("tax_amt");
}
public async void getaddresses()
{
ind_vis = true;
OnPropertyChanged("ind_vis");
int user_id = (int)App.Current.Properties["user_id"];
RestClient restClient = new RestClient();
var result = await restClient.Get_address(user_id); //calling restAPI method
if (result.status == "success")
{
ind_vis = false;
OnPropertyChanged("ind_vis");
public async Task<Address> Get_address(int user_id)
{
var formcontent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string,string>("user_id",user_id.ToString())
});
//returns from here// var response = await client.PostAsync(base_url + "api_delivery_details", formcontent).ConfigureAwait(false);
//executes later// var result = await response.Content.ReadAsStringAsync();
var Items = JsonConvert.DeserializeObject<Address>(result);
return Items;
}