Ejemplo n.º 1
0
        /// <summary>
        /// Add To Do to onenote page.
        /// </summary>
        /// <param name="todoText">To Do text.</param>
        /// <param name="pageContentUrl">page content url.</param>
        /// <returns>Ture if succeed.</returns>
        public async Task <bool> AddToDoToOneNote(string todoText, string pageContentUrl)
        {
            var todoContent = await this.httpClient.GetStringAsync(pageContentUrl + "/?includeIDs=true");

            var httpRequestMessage = ServiceHelper.GenerateAddToDoHttpRequest(todoText, todoContent, pageContentUrl);
            var result             = await this.httpClient.SendAsync(httpRequestMessage);

            return(result.IsSuccessStatusCode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a task.
        /// </summary>
        /// <param name="listType">Task list type.</param>
        /// <param name="taskText">The task text.</param>
        /// <returns>Ture if succeed.</returns>
        public async Task <bool> AddTaskAsync(string listType, string taskText)
        {
            try
            {
                var pageContentUrl = await this.GetDefaultToDoPageAsync(listType);

                var todoContent = await ExecuteContentFetchAsync(pageContentUrl.ContentUrl + "/?includeIDs=true");

                var httpRequestMessage = ServiceHelper.GenerateAddToDoHttpRequest(taskText, todoContent, pageContentUrl.ContentUrl);
                var result             = await ExecuteSendAsync(httpRequestMessage);

                return(result);
            }
            catch (ServiceException ex)
            {
                throw ServiceHelper.HandleGraphAPIException(ex);
            }
        }