/// <summary> /// Delete the specified lesson /// </summary> /// <param name="lsn">The lesson to delete</param> /// <returns></returns> public bool DeleteLesson(Lesson lsn) { try { Session.DbContext.Delete(lsn); return true; } catch { //Something went wrong return false; } }
/// <summary> /// Delete the specified lesson /// </summary> /// <param name="lsn">The lesson to be deleted</param> /// <returns></returns> public bool DeleteLesson(Lesson lsn) { try { return lsn.Unit.Lessons.Remove(lsn); } catch { return false; } }
/// <summary> /// Move a lesson into a unit /// </summary> /// <param name="lsn">The lesson to move</param> /// <param name="newUnt">The unit that the lesson is going into</param> /// <returns></returns> public bool MoveLesson(Lesson lsn, Unit newUnt) { try { lsn.UnitID = newUnt.ID; lsn.Unit = newUnt; //Remove the lesson from its current unit lsn.Unit.Lessons.Remove(lsn); //Move the lesson into its new unit newUnt.Lessons.Add(lsn); return true; } catch { //something went wrong return false; } }
/// <summary> /// Create a new lesson in the specified unit /// </summary> /// <param name="unt">The unit to create the lesson in</4param> /// <returns></returns> public bool CreateNewLesson(Unit unt) { try { Lesson newLesson = new Lesson(); newLesson.ID = Guid.NewGuid(); newLesson.UnitID = unt.ID; newLesson.Unit = unt; newLesson.LessonName = "New Lesson"; newLesson.LessonNum = (unt.Lessons.Count + 1); unt.Lessons.Add(newLesson); return true; } catch { return false; } }