Beispiel #1
0
 public T AddOne(T entity)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <T> dbset = context.Set <T>();
         var       some  = dbset.Add(entity);
         context.SaveChanges();
         return(some);
     }
 }
Beispiel #2
0
 public labdate AddLabdate(labdate labdate, int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <labdate> dbsetLabdate = context.Set <labdate>();
         labdate.lab_labID = id;
         labdate tmpLabdate = dbsetLabdate.Add(labdate);
         context.SaveChanges();
         return(tmpLabdate);
     }
 }
Beispiel #3
0
 public lab GetLabOfTask(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <task> dbsetTask = context.Set <task>();
         var          task      = dbsetTask.Find(id);
         context.Entry(task).Reference(s => s.lab).Load();
         context.SaveChanges();
         return(task.lab);
     }
 }
Beispiel #4
0
 public labdate GetLabdateOfPresent(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <present> dbsetPresent = context.Set <present>();
         present         presentTmp   = dbsetPresent.Find(id);
         context.Entry(presentTmp).Reference(s => s.labdate).Load();
         context.SaveChanges();
         return(presentTmp.labdate);
     }
 }
Beispiel #5
0
 public student GetStudentOfPresent(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <present> dbsetPresent = context.Set <present>();
         present         presentTmp   = dbsetPresent.Find(id);
         context.Entry(presentTmp).Reference(s => s.student).Load();
         context.SaveChanges();
         return(presentTmp.student);
     }
 }
Beispiel #6
0
 public List <course> GetCoursesOfLectruer(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lecturer> dbsetLectruer = context.Set <lecturer>();
         lecturer         lecturerTmp   = dbsetLectruer.Find(id);
         context.Entry(lecturerTmp).Collection(s => s.courses).Load(); // loads Courses collection
         context.SaveChanges();
         return(lecturerTmp.courses.ToList());
     }
 }
Beispiel #7
0
 public List <present> GetPresentsOfLabdate(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <labdate> dbsetLabdate = context.Set <labdate>();
         labdate         labdateTmp   = dbsetLabdate.Find(id);
         context.Entry(labdateTmp).Collection(s => s.presents).Load();
         context.SaveChanges();
         return(labdateTmp.presents.ToList());
     }
 }
Beispiel #8
0
 public List <lecturer> GetLecturerOfCourse(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <course> dbsetCourse = context.Set <course>();
         course         courseTmp   = dbsetCourse.Find(id);
         context.Entry(courseTmp).Collection(s => s.lecturers).Load();
         context.SaveChanges();
         return(courseTmp.lecturers.ToList());
     }
 }
Beispiel #9
0
 public task GetTaskOfTaskDone(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <taskdone> dbsetTaskDone = context.Set <taskdone>();
         var tD = dbsetTaskDone.Find(id);
         context.Entry(tD).Reference(s => s.task).Load();
         context.SaveChanges();
         return(tD.task);
     }
 }
Beispiel #10
0
 public lab GetLabOfLabdate(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <labdate> dbsetLabdate = context.Set <labdate>();
         labdate         labdateTmp   = dbsetLabdate.Find(id);
         context.Entry(labdateTmp).Reference(s => s.lab).Load();
         context.SaveChanges();
         return(labdateTmp.lab);
     }
 }
Beispiel #11
0
 public List <student> GetStudentsOfLab(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab> dbsetLab = context.Set <lab>();
         lab         labTmp   = dbsetLab.Find(id);
         context.Entry(labTmp).Collection(s => s.students).Load();
         context.SaveChanges();
         return(labTmp.students.ToList());
     }
 }
Beispiel #12
0
 public course GetCourseOfLab(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab> dbsetLab = context.Set <lab>();
         lab         labTmp   = dbsetLab.Find(id);
         context.Entry(labTmp).Reference(s => s.course).Load();
         context.SaveChanges();
         return(labTmp.course);
     }
 }
Beispiel #13
0
 public List <taskdone> GetTaskDonesOfTask(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <task> dbsetTask = context.Set <task>();
         var          task      = dbsetTask.Find(id);
         context.Entry(task).Collection(s => s.taskdones).Load();
         context.SaveChanges();
         return(task.taskdones.ToList());
     }
 }
Beispiel #14
0
 public List <present> GetPresentsOfStudent(int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <student> dbset = context.Set <student>();
         var             model = dbset.Find(id);
         context.Entry(model).Collection(s => s.presents).Load();
         context.SaveChanges();
         return(model.presents.ToList());
     }
 }
Beispiel #15
0
 public void AddStudToLab(student student, lab lab)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <student> dbsetStudent = context.Set <student>();
         DbSet <lab>     dbsetLab     = context.Set <lab>();
         var             tmpStud      = dbsetStudent.Find(student.studentID);
         var             tmpLab       = dbsetLab.Find(lab.labID);
         tmpStud.labs.Add(tmpLab);
         context.SaveChanges();
     }
 }
Beispiel #16
0
 public lab AddLab(lab lab, int id)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lab>    dbsetLab    = context.Set <lab>();
         DbSet <course> dbsetCourse = context.Set <course>();
         lab.course_courseID = id;
         lab tmplab = dbsetLab.Add(lab);
         context.SaveChanges();
         return(tmplab);
     }
 }
Beispiel #17
0
 public void AddLecturerToCourse(int lecturerID, int courseID)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <lecturer> dbsetLecturer = context.Set <lecturer>();
         DbSet <course>   dbsetCourse   = context.Set <course>();
         var tmpLec    = dbsetLecturer.Find(lecturerID);
         var tmpCourse = dbsetCourse.Find(courseID);
         tmpLec.courses.Add(tmpCourse);
         context.SaveChanges();
     }
 }
Beispiel #18
0
 public List <T> AddMany(List <T> entityList)
 {
     using (se02team06 context = new se02team06()) {
         DbSet <T> dbset2 = context.Set <T>();
         foreach (T item in entityList)
         {
             dbset2.Add(item);
         }
         context.SaveChanges();
         return(entityList);
     }
 }
Beispiel #19
0
 public void Remove(int id)
 {
     using (se02team06 context = new se02team06()) {
         try {
             DbSet <T> dbset = context.Set <T>();
             dbset.Remove(dbset.Find(id));
             context.SaveChanges();
         } catch (ArgumentNullException e) {
             Console.WriteLine("object with this id does not exist", e);
         } catch (Exception e) {
             Console.WriteLine(e);
         }
     }
 }
Beispiel #20
0
 public void Update(int id, T entry)
 {
     using (se02team06 context = new se02team06()) {
         try {
             DbSet <T> dbset = context.Set <T>();
             var       old   = dbset.Find(id);
             context.Entry(old).CurrentValues.SetValues(entry);
             context.SaveChanges();
         } catch (DbUpdateException e) {
             Console.WriteLine("object with this id does not exist", e);
         } catch (Exception e) {
             Console.WriteLine(e);
         }
     }
 }
Beispiel #21
0
 public void RemoveAll()
 {
     using (se02team06 context = new se02team06()) {
         try {
             DbSet <T> dbset      = context.Set <T>();
             List <T>  entityList = GetAll();
             foreach (var item in entityList)
             {
                 dbset.Attach(item);
                 dbset.Remove(item);
             }
             context.SaveChanges();
         } catch (Exception e) {
             Console.WriteLine("{0}Exception", e);
         }
     }
 }