public static instation GetInstationById(int id) { using (var context = new PARENTSEntities1()) { instation instationList = context.instation.FirstOrDefault(x => x.code == id); return(instationList); } }
public static List <instation> GetAllInstation() { using (var context = new PARENTSEntities1()) { List <instation> instationList = context.instation.ToList(); return(instationList); } }
public static List <classes> GetAllClasses() { using (var context = new PARENTSEntities1()) { List <classes> classesList = context.classes.ToList(); return(classesList); } }
// מחיקה public static void DeleteInstation(int code) { using (var context = new PARENTSEntities1()) { instation instation = context.instation.Where(p => p.code == code).FirstOrDefault(); context.instation.Remove(instation); context.SaveChanges(); } }
//הוספת public static int AddInstation(instation instation) { using (var context = new PARENTSEntities1()) { instation i = context.instation.Add(instation); context.SaveChanges(); return(i.code); } }
// מחיקה public static void DeleteClass(int code) { using (var context = new PARENTSEntities1()) { classes classes = context.classes.Where(p => p.code == code).FirstOrDefault(); context.classes.Remove(classes); context.SaveChanges(); } }
//הוספת public static int AddClass(classes classes) { using (var context = new PARENTSEntities1()) { context.Database.ExecuteSqlCommand("set identity_insert [dbo].[classes] on"); classes c = context.classes.Add(classes); context.SaveChanges(); context.Database.ExecuteSqlCommand("set identity_insert [dbo].[classes] of"); return(c.code); } }
//עדכון public static void UpdateClass(classes classes) { using (var context = new PARENTSEntities1()) { classes pro = context.classes.Where(p => p.code == classes.code).FirstOrDefault(); if (pro != null) { pro.code = classes.code; pro.num_class = classes.num_class; pro.id_teacher = classes.id_teacher; context.SaveChanges(); } } }
//עדכון public static void UpdateInstation(instation instation) { using (var context = new PARENTSEntities1()) { instation pro = context.instation.Where(p => p.code == instation.code).FirstOrDefault(); if (pro != null) { pro.code = instation.code; pro.email = instation.email; pro.NAME = instation.NAME; pro.password = instation.password; context.SaveChanges(); } } }
public static List <classes> GetClasesByCodeInstation(int id) { using (var context = new PARENTSEntities1()) { var c1 = context.classes.ToList(); var t1 = context.teachers.ToList(); var i1 = context.instation.ToList(); List <classes> classesList = (from c in c1 from t in t1 from i in i1 where c.id_teacher == t.id && t.code_instation == i.code && i.code == id select new classes { class_ = c.class_, code = c.code, id_teacher = c.id_teacher, num_class = c.num_class }).ToList(); return(classesList); } }