コード例 #1
0
        public void InitialSetup()
        {
            Repository = new AssessmentRepository();
            Context    = new StudentAssAttSysContext();

            CleanUp();
        }
コード例 #2
0
        public static void SeedModuleLinks(StudentAssAttSysContext db)
        {
            Module[] modules = db.Modules.ToArray();
            int      n       = 1;

            foreach (Module module in modules)
            {
                if (module.Lecturers == null)
                {
                    module.Lecturers = new List <Lecturer>();
                }

                if (module.Students == null)
                {
                    module.Students = new List <Student>();
                }

                if (n == 1)
                {
                    module.Lecturers.AddRange(db.Lecturers.ToList());
                    module.Students.AddRange(db.Students.ToList());
                }
                else
                {
                    module.Lecturers.Add(db.Lecturers.FirstOrDefault());
                    module.Students.Add(db.Students.FirstOrDefault());
                }
                db.Entry(module).State = EntityState.Modified;
                n++;
            }


            db.SaveChanges();
        }
コード例 #3
0
 public static void RemoveAll(StudentAssAttSysContext db)
 {
     RemoveAssessments(db);
     RemoveModules(db);
     RemoveStudents(db);
     RemoveLecturers(db);
 }
コード例 #4
0
 public static void SeedStudents(StudentAssAttSysContext db)
 {
     db.Students.AddRange(new List <Student>()
     {
         new Student
         {
             User = new User
             {
                 Id        = "S80611",
                 FirstName = "Joe",
                 LastName  = "Test",
                 Email     = "*****@*****.**"
             },
             StudentNumber = "S80611",
         },
         new Student
         {
             User = new User
             {
                 Id        = "S47223",
                 FirstName = "Brenda",
                 LastName  = "Test",
                 Email     = "*****@*****.**"
             },
             StudentNumber = "S47223"
         }
     });
     db.SaveChanges();
 }
コード例 #5
0
 public static void RemoveModules(StudentAssAttSysContext db)
 {
     foreach (var module in db.Modules)
     {
         db.Entry(module).State = EntityState.Deleted;
     }
     db.SaveChanges();
 }
コード例 #6
0
 public static void RemoveLecturers(StudentAssAttSysContext db)
 {
     foreach (var lectuer in db.Lecturers)
     {
         db.Entry(lectuer).State = EntityState.Deleted;
     }
     db.SaveChanges();
 }
コード例 #7
0
 public static void RemoveStudents(StudentAssAttSysContext db)
 {
     foreach (var student in db.Students)
     {
         db.Entry(student).State = EntityState.Deleted;
     }
     db.SaveChanges();
 }
コード例 #8
0
 public static void SeedAll(StudentAssAttSysContext db)
 {
     SeedStudents(db);
     SeedLecturers(db);
     SeedModules(db);
     SeedModuleLinks(db);
     SeedAssessment(db);
 }
コード例 #9
0
 public static void RemoveStudents(StudentAssAttSysContext db)
 {
     foreach (var student in db.Users.Where(u => u.Student != null))
     {
         db.Users.Remove(student);
         //db.Entry(student).State = EntityState.Deleted;
     }
     db.SaveChanges();
 }
コード例 #10
0
        public static void RemoveAssessments(StudentAssAttSysContext db)
        {
            //if (db.Assessments.Count() > 0)
            //{
            //    db.Assessments.RemoveRange(db.Assessments);

            //    db.SaveChanges();
            //}
        }
コード例 #11
0
 public static void SeedModules(StudentAssAttSysContext db)
 {
     db.Modules.AddRange(new List <Module>()
     {
         new Module
         {
             Name          = "Module 1",
             GPAPercentage = 20.0
         },
         new Module
         {
             Name          = "Module 2",
             GPAPercentage = 50.0
         }
     });
     db.SaveChanges();
 }
コード例 #12
0
 public static void SeedAssessment(StudentAssAttSysContext db)
 {
     db.Assessments.AddRange(new List <Assessment>()
     {
         new Assessment
         {
             DateTimeStart = DateTime.Now.AddHours(-1),
             DateTimeEnd   = DateTime.Now.AddHours(1),
             LecturerId    = db.Lecturers.FirstOrDefault().Id,
             ModuleId      = db.Modules.FirstOrDefault().Id
         },
         new Assessment
         {
             DateTimeStart = DateTime.Now.AddHours(-1),
             DateTimeEnd   = DateTime.Now.AddHours(1),
             LecturerId    = db.Lecturers.FirstOrDefault().Id,
             ModuleId      = db.Modules.FirstOrDefault().Id
         }
     });
     db.SaveChanges();
 }
コード例 #13
0
 public static void SeedLecturers(StudentAssAttSysContext db)
 {
     db.Lecturers.AddRange(new List <Lecturer>()
     {
         new Lecturer
         {
             Id        = "JLect",
             FirstName = "John",
             LastName  = "Test",
             Email     = "*****@*****.**"
         },
         new Lecturer
         {
             Id        = "BLect",
             FirstName = "Bali",
             LastName  = "Test",
             Email     = "*****@*****.**"
         }
     });
     db.SaveChanges();
 }
コード例 #14
0
 public static void RemoveModules(StudentAssAttSysContext db)
 {
     db.Modules.RemoveRange(db.Modules);
     db.SaveChanges();
 }
コード例 #15
0
 public LecturerRepository()
 {
     context = new StudentAssAttSysContext();
 }
コード例 #16
0
 public static void RemoveLecturers(StudentAssAttSysContext db)
 {
     db.Users.RemoveRange(db.Users);
     db.SaveChanges();
 }
コード例 #17
0
 public StudentRepository()
 {
     context = new StudentAssAttSysContext();
 }
コード例 #18
0
 public AttendanceRepository()
 {
     context = new StudentAssAttSysContext();
 }
コード例 #19
0
 public void InitialSetup()
 {
     Repository = new CommentRepository();
     Context    = new StudentAssAttSysContext();
 }