public bool DeleteExpectation(LessonExpectation expectation) { try { CurLesson.LessonExpectations.Remove(expectation); try { Helper.Session.DbContext.Delete(expectation); } catch { // This error is generally caused by a user deleting an item // before it has been saved to the database. // Because of this, we can ignore this error } return true; } catch { //An error occured while deleted the document record return false; } }
/// <summary> /// Create a lesson expectation for the given lesson and expectation if one doesn't already exist in the current lesson /// </summary> /// <param name="exp"></param> /// <returns></returns> public LessonExpectation AddLessonExpectation(Expectation exp) { LessonExpectation lsnExpectation = new LessonExpectation(); try { //Make sure the expectation hasn't already been added to the lesson if (CurLesson.LessonExpectations != null) { foreach (LessonExpectation lsnExp in CurLesson.LessonExpectations) { if (lsnExp.SENumber == exp.Senumber) return null; } } lsnExpectation.Expectation = exp; lsnExpectation.Lesson = CurLesson; lsnExpectation.LessonDOK = 0; lsnExpectation.LessonID = CurLesson.ID; lsnExpectation.SENumber = exp.Senumber; lsnExpectation.UnitDOK = 0; return lsnExpectation; } catch { //An error occured return null; } finally { lsnExpectation = null; } }