public async Task <AsanaResponse <AsanaTask> > UpdateTask(AsanaTaskDTO newTask) { return(await UseRequest <AsanaTask>( string.Format("tasks/{0}", newTask.id), request => { var fields = new List <string> { "name", "notes", "completed", "assignee_status" }; fields.Add("due_on"); fields.Add("assignee"); //if(newTask.followers.Any()) //{ // fields.Add("followers"); //} request.Method = Method.PUT; request.AddObject(newTask, fields.ToArray()); })); }
public static AsanaTaskDTO CreateTaskDTO(long id, string name, string notes, long projectId, string assigneeStatus, long assigneeId, bool completed, DateTime?dueDate, List <long> followers) { var dto = new AsanaTaskDTO(); dto.id = id; dto.assignee_status = assigneeStatus; dto.assignee = assigneeId > 0 ? assigneeId.ToString() : AsanaConstants.Utils.NULL_VALUE; dto.completed = completed; if (dueDate.HasValue) { dto.due_on = dueDate.Value.ToString("yyyy-MM-dd"); } else { dto.due_on = AsanaConstants.Utils.NULL_VALUE; } dto.name = name; dto.notes = notes; dto.projects = projectId; if (followers != null) { dto.followers = followers.Select(c => new AsanaFollower() { id = c }).ToList(); } return(dto); }
public async Task <AsanaResponse <AsanaTask> > UpdateTask(AsanaTaskDTO newTask) { return(await UseRequest <AsanaTask>( string.Format("tasks/{0}", newTask.id), (request, container) => { var fields = new List <string> { "name", "notes", "completed", "assignee_status" }; fields.Add("due_on"); fields.Add("assignee"); request.Method = HttpMethod.Put; container.AddObject(newTask, fields.ToArray()); })); }
public async Task <AsanaResponse <AsanaTask> > CreateTask(long workspaceId, AsanaTaskDTO newTask, long?parentId) { var fields = new List <string> { "name", "notes", "completed", "due_on", "assignee_status" }; if (newTask.projects > 0 && parentId == null) { fields.Add("projects"); } if (newTask.due_on != null) { fields.Add("due_on"); } fields.Add("assignee"); var url = parentId.HasValue ? GetSubTasksUrl(parentId.Value) : GetWorkspaceTasksUrl(workspaceId); return(await UseRequest <AsanaTask>(url, (request, container) => { request.Method = HttpMethod.Post; container.AddObject(newTask, fields.ToArray()); if (newTask.followers != null) { foreach (var asanaFollower in newTask.followers) { container.JsonData.Add(string.Format("followers[{0}]", newTask.followers.IndexOf(asanaFollower)), asanaFollower.id); } } })); }