public void AddProtocol(int studentID, string value, string hoursTotal, int subjectID, DateTime date) { int hours = Int32.Parse(hoursTotal); Protocol protocol = new Protocol(); protocol.StudentID = studentID; protocol.HoursTotal = hours; switch (value) { case "Present": protocol.HoursPresent = hours; protocol.HoursVirtual = 0; break; case "Virtual": protocol.HoursPresent = 0; protocol.HoursVirtual = hours; break; case "Absent": protocol.HoursPresent = 0; protocol.HoursVirtual = 0; break; } if (date == DateTime.Now.Date) { protocol.Date = DateTime.Now.Date; } else { protocol.Date = date; } protocol.SubjectID = subjectID; Protocol protocolobj; protocolobj = context.Protocols.FirstOrDefault(p => p.Date == date && p.SubjectID == subjectID && p.StudentID == studentID); // && p.HoursPresent == protocol.HoursPresent && p.HoursVirtual == protocol.HoursVirtual if (protocolobj == null) { context.Add(protocol); context.SaveChanges(); } else if (protocolobj != null) { DeleteProtocol(protocolobj); context.Add(protocol); context.SaveChanges(); } }
public static void EnsurePopulated(IApplicationBuilder app) { FFDbContext context = app.ApplicationServices.CreateScope().ServiceProvider .GetRequiredService <FFDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Subjects.Any()) { context.Subjects.AddRange( new Subject { Name = "DMU-19 ProTek3" }, new Subject { Name = "DMU-19 Sysudvikling3" }, new Subject { Name = "DMU-19 Databaser" }, new Subject { Name = "DMU-20 ProTek3" }, new Subject { Name = "DMU-20 Sysudvikling3" }, new Subject { Name = "DMU-20 Databaser" } ); } context.SaveChanges(); }
public static void EnsurePopulated(IApplicationBuilder app) { FFDbContext context = app.ApplicationServices.CreateScope().ServiceProvider .GetRequiredService <FFDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.StudentsSubjects.Any()) { context.StudentsSubjects.AddRange( new StudentsSubjects { StudentID = 1, SubjectID = 1 }, new StudentsSubjects { StudentID = 2, SubjectID = 1 }, new StudentsSubjects { StudentID = 3, SubjectID = 2 } ); } context.SaveChanges(); }
public static void EnsurePopulated(IApplicationBuilder app) { FFDbContext context = app.ApplicationServices.CreateScope().ServiceProvider .GetRequiredService <FFDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Protocols.Any()) { context.Protocols.AddRange( new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 1, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 2, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 3, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 4, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 5, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 6, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 7, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 8, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 9, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 10, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 11, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 12, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 13, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 14, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 15, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 16, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 17, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 18, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 19, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 20, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("10-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 21, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 1, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 2, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 3, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 4, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 5, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 6, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 7, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 8, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 9, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 10, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 11, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 12, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 13, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 14, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 15, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 16, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 17, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 18, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 19, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("11-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 20, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 21, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 1, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 2, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 3, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 4, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 5, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 6, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 7, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 8, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 9, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 10, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 11, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 12, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 13, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 14, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 15, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 16, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 17, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 18, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 19, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 20, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("12-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 21, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 1, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 2, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 3, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 4, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 5, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 6, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 7, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 8, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 9, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 10, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 11, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 12, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 13, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 14, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 15, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 16, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 17, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 18, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 2, HoursVirtual = 0, StudentID = 19, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 2, StudentID = 20, SubjectID = 1 }, new Protocol { Date = DateTime.Parse("13-12-2020"), HoursTotal = 2, HoursPresent = 0, HoursVirtual = 0, StudentID = 21, SubjectID = 1 } ); } context.SaveChanges(); }
public static void EnsurePopulated(IApplicationBuilder app) { FFDbContext context = app.ApplicationServices.CreateScope().ServiceProvider .GetRequiredService <FFDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Students.Any()) { context.Students.AddRange( new Student { Name = "Bjarke Villadsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Casper Nielsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Christian Nygaard Pedersen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Claus Jørgensen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Daniel Bjerre Madsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Dean Marco Dalager Birch Nielsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Emil Overgaard Jensen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Jack Jakobsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Jakob Rasmussen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Mads Brandt", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Mark Enggaard", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Mark Pearson", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Martin Godthaab Larsen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Mathias Jensen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Pia Degn Eriksen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Sabine Amtkjær", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Simon Markussen", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Søren Kaalund", Email = "sø[email protected]", IsActive = true }, new Student { Name = "Victor Eriksen Siig", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Viktor Juul", Email = "*****@*****.**", IsActive = true }, new Student { Name = "Yasin Güler", Email = "*****@*****.**", IsActive = true } ); } context.SaveChanges(); }
public void DeleteStudentSubject(StudentsSubjects ss) { context.Remove(ss); context.SaveChanges(); }
public void AddSubject(Subject subject) { context.Add(subject); context.SaveChanges(); }