/// <summary>
        /// Updates the task with new values
        /// </summary>
        /// <remarks>Uses reflection to iterate properties, so does carry some overhead in terms of performance</remarks>
        /// <param name="user">The user to get the ApiToken from</param>
        /// <param name="story">The story the task belongs to</param>
        /// <returns>The updated task instance</returns>
        public PivotalTask UpdateTask(PivotalUser user, PivotalStory story)
        {
            PivotalTask updatedTask = PivotalTask.UpdateTask(user, story.ProjectId.GetValueOrDefault(), story.Id.GetValueOrDefault(), this);

            System.Reflection.PropertyInfo[] properties = this.GetType().GetProperties();
            foreach (System.Reflection.PropertyInfo p in properties)
            {
                p.SetValue(this, p.GetValue(updatedTask, null), null);
            }
            return(this);
        }
        /// <summary>
        /// Adds a story to Pivotal
        /// </summary>
        /// <param name="user">The user to get the ApiToken from</param>
        /// <param name="projectId">The id of the project</param>
        /// <param name="story">The story to add</param>
        /// <param name="saveTasks">Controls whether any tasks associated with the story should also be saved.</param>
        /// <returns>The created story</returns>
        public static PivotalStory AddStory(PivotalUser user, int projectId, PivotalStory story, bool saveTasks)
        {
            string       url        = String.Format("{0}/projects/{1}/stories?token={2}", PivotalService.BaseUrl, projectId.ToString(), user.ApiToken);
            XmlDocument  xml        = SerializationHelper.SerializeToXmlDocument <PivotalStory>(story);
            string       storyXml   = PivotalService.CleanXmlForSubmission(xml, "//story", ExcludeNodesOnSubmit, true);
            XmlDocument  response   = PivotalService.SubmitData(url, storyXml, ServiceMethod.POST);
            PivotalStory savedStory = SerializationHelper.DeserializeFromXmlDocument <PivotalStory>(response);

            if (saveTasks)
            {
                foreach (PivotalTask task in story.Tasks)
                {
                    if (task.TaskId.HasValue)
                    {
                        PivotalTask.UpdateTask(user, projectId, savedStory.Id.GetValueOrDefault(), task);
                    }
                    else
                    {
                        PivotalTask.AddTask(user, projectId, savedStory.Id.GetValueOrDefault(), task);
                    }
                }
            }
            return(savedStory);
        }