public static bool AddCategory(CATEGORY category) { using (CloudEDUEntities ctx = new CloudEDUEntities()) { try { ctx.Set<CATEGORY>().Add(category); ctx.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); return false; } } return true; }
public static bool UpdateCategory(CATEGORY category) { using (CloudEDUEntities ctx = new CloudEDUEntities()) { try { ctx.Entry(category).State = System.Data.EntityState.Modified; ctx.SaveChanges(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); return false; } } return true; }
public static COURSE[] GetCoursesByCategory(CATEGORY category) { COURSE[] courses = null; using (CloudEDUEntities ctx = new CloudEDUEntities()) { courses = ctx.COURSEs.Where(c => c.CATEGORY == category.ID).ToArray(); } return courses; }