public void InitialSetup() { Repository = new AssessmentRepository(); Context = new StudentAssAttSysContext(); CleanUp(); }
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(); }
public static void RemoveAll(StudentAssAttSysContext db) { RemoveAssessments(db); RemoveModules(db); RemoveStudents(db); RemoveLecturers(db); }
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(); }
public static void RemoveModules(StudentAssAttSysContext db) { foreach (var module in db.Modules) { db.Entry(module).State = EntityState.Deleted; } db.SaveChanges(); }
public static void RemoveLecturers(StudentAssAttSysContext db) { foreach (var lectuer in db.Lecturers) { db.Entry(lectuer).State = EntityState.Deleted; } db.SaveChanges(); }
public static void RemoveStudents(StudentAssAttSysContext db) { foreach (var student in db.Students) { db.Entry(student).State = EntityState.Deleted; } db.SaveChanges(); }
public static void SeedAll(StudentAssAttSysContext db) { SeedStudents(db); SeedLecturers(db); SeedModules(db); SeedModuleLinks(db); SeedAssessment(db); }
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(); }
public static void RemoveAssessments(StudentAssAttSysContext db) { //if (db.Assessments.Count() > 0) //{ // db.Assessments.RemoveRange(db.Assessments); // db.SaveChanges(); //} }
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(); }
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(); }
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(); }
public static void RemoveModules(StudentAssAttSysContext db) { db.Modules.RemoveRange(db.Modules); db.SaveChanges(); }
public LecturerRepository() { context = new StudentAssAttSysContext(); }
public static void RemoveLecturers(StudentAssAttSysContext db) { db.Users.RemoveRange(db.Users); db.SaveChanges(); }
public StudentRepository() { context = new StudentAssAttSysContext(); }
public AttendanceRepository() { context = new StudentAssAttSysContext(); }
public void InitialSetup() { Repository = new CommentRepository(); Context = new StudentAssAttSysContext(); }