/// <summary> /// Accesses the /tasks/{id}/setParent endpoint. /// </summary> /// <returns></returns> public async Task<AsanaUser> SetParent(AsanaTask parent) { var request = new RestRequest("/tasks/{id}/setParent", Method.GET); request.AddUrlSegment("id", Id.ToString()); request.AddParameter("parent", parent.ToString()); // execute the request var response = await AsanaHost.RestClient.ExecuteTaskAsync(request); using (var stringReader = new StringReader(response.Content)) // raw content as string using (var reader = new JsonTextReader(stringReader)) { var jsonData = AsanaHost.JsonDeserializer.Deserialize<AsanaResponse>(reader); if (!ReferenceEquals(jsonData.Errors, null)) // || !string.IsNullOrEmpty(jsonData.Errors.Message) throw new Exception("A remote error has occured: " + jsonData.Errors.First().Message); return jsonData.Data.ToObject<AsanaUser>(AsanaHost.JsonDeserializer); } }
/// <summary> /// Accesses the /tasks/{id}/addProject endpoint. /// </summary> /// <returns></returns> public async Task AddProject(AsanaProject project, AsanaTask section = null, AsanaTask insertAfter = null, AsanaTask insertBefore = null) { var request = new RestRequest("/tasks/{id}/addProject", Method.POST); request.AddUrlSegment("id", Id.ToString()); request.AddParameter("project", project.ToString()); if (!ReferenceEquals(section, null)) request.AddParameter("section", section.ToString()); if (!ReferenceEquals(insertAfter, null)) request.AddParameter("insert_after", insertAfter.ToString()); if (!ReferenceEquals(insertBefore, null)) request.AddParameter("insert_before", insertBefore.ToString()); // execute the request var response = await AsanaHost.RestClient.ExecuteTaskAsync(request); using (var stringReader = new StringReader(response.Content)) // raw content as string using (var reader = new JsonTextReader(stringReader)) { var jsonData = AsanaHost.JsonDeserializer.Deserialize<AsanaResponse>(reader); if (!ReferenceEquals(jsonData.Errors, null)) // || !string.IsNullOrEmpty(jsonData.Errors.Message) throw new Exception("A remote error has occured: " + jsonData.Errors.First().Message); } }