//public List<AssignmentAttempt> GetAssignmentAttemptsByDateRange(DateTime startDate, DateTime endDate) //{ // var assignmentAttempts = from assignmentAttempt in GetAllAssignmentAttempts() // where assignmentAttempt.Date >= startDate // && assignmentAttempt.Date <= endDate // select assignmentAttempt; // return new List<AssignmentAttempt>(assignmentAttempts); //} public void SaveNewAssignmentAttempt(AssignmentAttempt assignmentAttempt) { string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename); try { XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt); if (assignmentAttemptFile != null) { assignmentAttemptFile.Element("AssignmentAttempts").Add(assignmentAttempt.GetXMLNode()); assignmentAttemptFile.Save(fileName); } } catch (FileNotFoundException ex) { System.Diagnostics.Debug.Write(ex.Message); } }
public void UpdateAssignmentAttempt(AssignmentAttempt assignmentAttempt) { string fileName = Path.Combine(filePath, Properties.Settings.Default.assignmentAttempsFilename); try { XDocument assignmentAttemptFile = OpenFile(fileName, MMFileType.AssignmentAttempt); if (assignmentAttemptFile != null) { assignmentAttemptFile.Descendants("AssignmentAttempt").First(s => s.Element("ID").Value == assignmentAttempt.ID).ReplaceWith(assignmentAttempt.GetXMLNode()); assignmentAttemptFile.Save(fileName); } } catch (FileNotFoundException ex) { System.Diagnostics.Debug.Write(ex.Message); } catch (ArgumentNullException ex) { System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed null referance.\n" + ex.Message); } catch (InvalidOperationException ex) { System.Diagnostics.Debug.Write(DateTime.Now.ToString() + " UpdateAssignmentAttempt failed Invalid Operation.\n" + ex.Message); } }