private static bool AddResourcesToLesson(RESOURCE[] res, LESSON lesson) { using (CloudEDUEntities ctx = new CloudEDUEntities()) { var ls = ctx.LESSONs.Include("RESOURCEs").Where(l => l.ID == lesson.ID).FirstOrDefault(); foreach (RESOURCE rs in res) ls.RESOURCEs.Add(rs); ctx.Entry(ls).State = System.Data.EntityState.Modified; ctx.SaveChanges(); } return true; }
private static bool AddLessonsToCourse(LESSON[] lessons, COURSE course) { using (CloudEDUEntities ctx = new CloudEDUEntities()) { try { var cs = ctx.COURSEs.Include("LESSONs").Where(c => c.ID == course.ID).FirstOrDefault(); foreach (LESSON ls in lessons) cs.LESSONs.Add(ls); ctx.Entry(cs).State = System.Data.EntityState.Modified; ctx.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); return false; } } return true; }
public static bool RemoveLesson(LESSON lesson) { using (CloudEDUEntities ctx = new CloudEDUEntities()) { try { ctx.Set<LESSON>().Attach(lesson); ctx.Set<LESSON>().Remove(lesson); ctx.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); return false; } } return true; }
public static RESOURCE[] GetResourcesByLesson(LESSON lesson) { RESOURCE[] resources = null; using (CloudEDUEntities ctx = new CloudEDUEntities()) { var rs = ctx.LESSONs.Include("RESOURCEs").Where(l => l.ID == lesson.ID).FirstOrDefault(); resources = rs.RESOURCEs.ToArray(); } return resources; }
public static NOTE_SHARABLE[] GetNoteSharableByLesson(LESSON lesson) { NOTE_SHARABLE[] notes = null; using (CloudEDUEntities ctx = new CloudEDUEntities()) { notes = ctx.NOTE_SHARABLE.Where(n => n.LESSON_ID == lesson.ID).ToArray(); } return notes; }
public static DOCUMENT[] GetDocumentsByLesson(LESSON lesson) { DOCUMENT[] documents = null; using (CloudEDUEntities ctx = new CloudEDUEntities()) { var ls = ctx.LESSONs.Include("DOCUMENTs").Where(l => l.ID == lesson.ID).FirstOrDefault(); documents = ls.DOCUMENTs.ToArray(); } return documents; }