/// <summary> /// 31 March 2014 /// Jonathan Sanborn /// Decoupled Assignments and FileHandler /// /// </summary> /// <param name="assignment">The Assignment to be saved in XMl file</param> public void SaveNewAssignment(Assignment assignment) { string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentFilename); try { XDocument assignmentFile = OpenFile(fileName, MMFileType.Assignment); if (assignmentFile != null) { assignmentFile.Element("Assignments").Add(assignment.GetXMLNode()); assignmentFile.Save(fileName); } } catch (FileNotFoundException ex) { System.Diagnostics.Debug.Write(ex.Message); } }
/// <summary> /// Jonathan Sanborn /// /// Updates the XML of the passed in assignment /// </summary> /// <param name="assignment">The assignment to update</param> public void UpdateAssignment(Assignment assignment) { string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentFilename); try { XDocument assignmentFile = OpenFile(fileName, MMFileType.Assignment); if (assignmentFile != null) { assignmentFile.Descendants("Assignment").First(s => s.Element("ID").Value == assignment.ID).ReplaceWith(assignment.GetXMLNode()); assignmentFile.Save(fileName); } } catch (FileNotFoundException ex) { System.Diagnostics.Debug.Write(ex.Message); } }