Пример #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
 public static bool RemoveResource(RESOURCE resource)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Set<RESOURCE>().Attach(resource);
             ctx.Set<RESOURCE>().Remove(resource);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }