Пример #1
0
 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;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
 }