private async Task <bool> ExecuteSendAsync(HttpRequestMessage request) { var result = await httpClient.SendAsync(request); if (result.IsSuccessStatusCode) { return(true); } else { dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }
private async Task <dynamic> ExecuteContentFetchAsync(string url) { var result = await httpClient.GetAsync(url); var responseContent = await result.Content.ReadAsStringAsync(); if (result.IsSuccessStatusCode) { return(responseContent); } else { var serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }
private async Task <string> ExecuteGraphFetchAsync(string url) { var result = await this.httpClient.GetAsync(url); dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); if (result.IsSuccessStatusCode) { return(JsonConvert.SerializeObject((object)responseContent.value)); } else { ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }
private async Task <bool> ExecuteTaskAddAsync(string url, string taskText) { var httpRequestMessage = ServiceHelper.GenerateAddOutlookTaskHttpRequest(url, taskText); var result = await this.httpClient.SendAsync(httpRequestMessage); if (result.IsSuccessStatusCode) { return(true); } else { dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }
private async Task <bool> ExecuteTasksDeleteAsync(string url, List <TaskItem> taskItems) { foreach (var taskItem in taskItems) { var httpRequestMessage = ServiceHelper.GenerateDeleteOutlookTaskHttpRequest(url, taskItem); var result = await this.httpClient.SendAsync(httpRequestMessage); if (!result.IsSuccessStatusCode) { dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } } return(true); }
private async Task <string> CreateTaskFolderAsync(string taskFolderName) { var httpRequestMessage = ServiceHelper.GenerateCreateTaskFolderHttpRequest(GraphBaseUrl + "taskFolders", taskFolderName); var result = await this.httpClient.SendAsync(httpRequestMessage); dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); if (result.IsSuccessStatusCode) { return((string)responseContent.id); } else { ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }
private async Task <string> CreateOneNoteSectionAsync(string sectionContentUrl, string sectionTitle) { var makeSectionContent = await ExecuteContentFetchAsync(sectionContentUrl); var httpRequestMessage = ServiceHelper.GenerateCreateSectionHttpRequest(makeSectionContent, sectionContentUrl, sectionTitle); var result = await httpClient.SendAsync(httpRequestMessage); dynamic responseContent = JObject.Parse(await result.Content.ReadAsStringAsync()); if (result.IsSuccessStatusCode) { return((string)responseContent.id); } else { ServiceException serviceException = ServiceHelper.GenerateServiceException(responseContent); throw serviceException; } }