/// <summary> /// Adds a task to the story /// </summary> /// <param name="user">The user to get the ApiToken from</param> /// <param name="projectId">The project id</param> /// <param name="storyId">The story id</param> /// <param name="task">The task to add</param> /// <returns>The created task</returns> public static PivotalTask AddTask(PivotalUser user, int projectId, int storyId, PivotalTask task) { string url = String.Format("{0}/projects/{1}/stories/{2}/tasks?token={3}", PivotalService.BaseUrl, projectId, storyId, user.ApiToken); XmlDocument xml = SerializationHelper.SerializeToXmlDocument<PivotalTask>(task); string taskXml = PivotalService.CleanXmlForSubmission(xml, "//story", ExcludeNodesOnSubmit, true); XmlDocument response = PivotalService.SubmitData(url, taskXml, ServiceMethod.POST); return SerializationHelper.DeserializeFromXmlDocument<PivotalTask>(response); }
/// <summary> /// Deletes a task from a story /// </summary> /// <param name="user">The user to get the ApiToken from</param> /// <param name="projectId">The project id</param> /// <param name="storyId">The story id</param> /// <param name="task">The task to delete</param> /// <returns></returns> public static PivotalTask DeleteTask(PivotalUser user, int projectId, int storyId, PivotalTask task) { string url = String.Format("{0}/projects/{1}/story/{2}/task/{3}?token={4}", PivotalService.BaseUrl, projectId, storyId, task.TaskId.GetValueOrDefault().ToString(), user.ApiToken); XmlDocument xml = SerializationHelper.SerializeToXmlDocument<PivotalTask>(task); string taskXml = PivotalService.CleanXmlForSubmission(xml, "//task", ExcludeNodesOnSubmit, true); XmlDocument response = PivotalService.SubmitData(url, taskXml, ServiceMethod.DELETE); return task; }
/// <summary> /// Updates the cache of tasks for the story and returns the list /// </summary> /// <param name="user">The user to get the ApiToken from</param> /// <returns></returns> public IList <PivotalTask> LoadTasks(PivotalUser user) { Tasks = PivotalTask.FetchTasks(user, ProjectId.GetValueOrDefault(), Id.GetValueOrDefault(), ""); return(Tasks); }