// http://blog.stephencleary.com/2012/02/async-and-await.html public async Task <HQBranchOffice> GetBranchOffice(int branchOfficeId) { string url = this.BuildUrl("/api/branch_offices/" + branchOfficeId); string json = await commonRequestOperation(url); // deserialize the json response into C# objects HQBranchOffice result = Newtonsoft.Json.JsonConvert.DeserializeObject < HQBranchOffice>(json); return(result); }
// http://blog.stephencleary.com/2012/02/async-and-await.html public async Task <HQBranchOffice> GetBranchOffice(int branchOfficeId) { string url = this.BuildUrl("/api/branch_offices/" + branchOfficeId); var response = await commonRequestOperation(url); if (response.StatusCode == HttpStatusCode.NotFound) { return(null); } string json = await response.Content.ReadAsStringAsync(); // deserialize the json response into C# objects HQBranchOffice result = Newtonsoft.Json.JsonConvert.DeserializeObject < HQBranchOffice>(json); return(result); }