Ejemplo n.º 1
0
        /// <summary>
        /// Update the indicated project.
        /// </summary>
        /// <param name="projectID">Project identifier.</param>
        /// <param name="projectName">Project's name.</param>
        /// <returns>Indicates if the modification has been made.</returns>
        public async Task <bool> UpdateProjectAsync(long projectID, string projectName)
        {
            var parameters = new ProjectJson(projectName);

            RestResponse result = await _callerRestApiTodoist.CallRestMethodAsync(Method.Post, $"projects/{ projectID }", Guid.NewGuid().ToString(), null, parameters);

            return(result.StatusCode == System.Net.HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a project.
        /// </summary>
        /// <param name="projectName">Project's name.</param>
        /// <returns>Project created.</returns>
        public async Task <ProjectModel> CreateProjectAsync(string projectName)
        {
            var parameters = new ProjectJson(projectName);

            RestResponse result = await _callerRestApiTodoist.CallRestMethodAsync(Method.Post, "projects", Guid.NewGuid().ToString(), null, parameters);

            if (result.StatusCode == System.Net.HttpStatusCode.OK &&
                result.ContentType == "application/json")
            {
                return(JsonConvert.DeserializeObject <ProjectModel>(result.Content));
            }

            return(null);
        }