コード例 #1
0
 public static bool AddRecommendation(RECOMMENDATION reco)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Set<RECOMMENDATION>().Add(reco);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #2
0
        public static bool AddCourseToRecommendation(COURSE course, RECOMMENDATION reco)
        {
            using (CloudEDUEntities ctx = new CloudEDUEntities())
            {
                try
                {
                    var rc = ctx.RECOMMENDATIONs.Include("COURSEs").Where(r => r.ID == reco.ID).FirstOrDefault();
                    var cs = ctx.COURSEs.Where(c => c.ID == course.ID).FirstOrDefault();
                    rc.COURSEs.Add(cs);
                    ctx.Entry(rc).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 UpdateRecommendation(RECOMMENDATION reco)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Entry(reco).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #4
0
 public static bool RemoveCourseFromRecommendation(COURSE course, RECOMMENDATION reco)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.RECOMMENDATIONs.Attach(reco);
             ctx.COURSEs.Attach(course);
             reco.COURSEs.Remove(course);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #5
0
 public static COURSE[] GetCoursesByRecommendation(RECOMMENDATION reco)
 {
     COURSE[] courses = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         var rc = ctx.RECOMMENDATIONs.Include("COURSEs").Where(r => r.ID == reco.ID).FirstOrDefault();
         courses = rc.COURSEs.ToArray();
     }
     return courses;
 }