public async Task <AdditionalAssignmentDto> CreateAdditionalAssignment(AdditionalAssignmentDto additionalAssignmentDto) { var aa = new AdditionalAssignment(); mapper.Map(additionalAssignmentDto, aa); var result = await context.AdditionalAssignments.AddAsync(aa); await context.SaveChangesAsync(); return(mapper.Map <AdditionalAssignmentDto>(result.Entity)); }
public static StatementSyntax CreateAssignment(AdditionalAssignment additionalAssignment) { var assign = SyntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, additionalAssignment.LeftHandSide, additionalAssignment.RightHandSide); return(SyntaxFactory.ExpressionStatement(assign)); }
public static void SeedDatabase(AppDbContext context) { context.Database.Migrate(); if (context.Lecturers.Count() == 0 && context.Modules.Count() == 0 && context.ModuleRuns.Count() == 0 && context.Semesters.Count() == 0 && context.AdditionalAssignments.Count() == 0) { ICollection <ModuleRun> mrcol = new List <ModuleRun>(); ICollection <AdditionalAssignment> aacol = new List <AdditionalAssignment>(); ICollection <LecturerModuleRun> lmrcol = new List <LecturerModuleRun>(); LecturerModuleRun lmr = new LecturerModuleRun(); // Seed data for module Module m2 = AddModule(context, "Project and Training 2", "BTI3011", 6, 8, 516); Module project2 = AddModule(context, "Projekt 2", "BTI7302", 6, 1, 25); AddModule(context, "User-Centered Design", "BTI7083", 4, 4, 100); Module projectAndTraining1 = new Module { Title = "Project and Training 1", Code = "BTI3001", ECTS = 6, LectPerWeek = 8, TotalHours = 516 }; Module m3 = new Module { Title = "E-Business and Web", Code = "BTI7272", ECTS = 8, LectPerWeek = 8, TotalHours = 408 }; Module m4 = new Module { Title = "Bachelor-Thesis", Code = "BTI7321", ECTS = 12, LectPerWeek = 0, TotalHours = 0 }; Module m5 = new Module { Title = "Smart Data-Driven Application", Code = "BTI7293", ECTS = 8, LectPerWeek = 8, TotalHours = 516 }; Module m6 = new Module { Title = "Einführung in C#", Code = "BTI7512", ECTS = 2, LectPerWeek = 2, TotalHours = 109 }; Module m7 = new Module { Title = "Grundlagen Geoinformationssysteme", Code = "BTI7538", ECTS = 2, LectPerWeek = 2, TotalHours = 100 }; Module m8 = new Module { Title = "Software Engineering and Design", Code = "BTX8081", ECTS = 8, LectPerWeek = 6, TotalHours = 300 }; Module m9 = new Module { Title = "Software Engineering and Design", Code = "BTX8082", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; Module databases = new Module { Title = "Databases (F)", Code = "BTI1311", ECTS = 4, LectPerWeek = 4, TotalHours = 208 }; Module m12 = new Module { Title = "Datenbanken", Code = "BTW2201", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; Module studienBeratung = new Module { Title = "Studienberatung SG I", Code = "", ECTS = 0, LectPerWeek = 4, TotalHours = 200 }; Module computing_project = new Module { Title = "Computing Project", Code = "BTI6453", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; Module intro_multim = new Module { Title = "Introduction to Multimedia", Code = "BTI6454", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; Module prof_skills = new Module { Title = "Professional Skills", Code = "BTI6456", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; context.Modules.AddRange(m3, m4, m5, m6, m7, m8, m9, databases, m12, studienBeratung, projectAndTraining1, computing_project, intro_multim, prof_skills); context.SaveChanges(); // Seed data for AdditionalAssignments AdditionalAssignment a1 = new AdditionalAssignment { Title = "aF&E", AAHours = 0, }; AdditionalAssignment a2 = new AdditionalAssignment { Title = "FB-Pool Abteilung Informatik", AAHours = 0 }; context.AdditionalAssignments.AddRange(a1, a2); context.SaveChanges(); //seed data for lecturer Lecturer margo = new Lecturer { FirstName = "Margo", LastName = "White", Email = "*****@*****.**", BirthDate = new DateTime(1983, 04, 11), Gender = Gender.Female, PhotoPath = "images/margo.jpg", IsDeleted = false, WorkingHours = 1300.0, Role = Role.LECTURER }; Lecturer rosita = new Lecturer { FirstName = "Rosita", LastName = "Penni", Email = "*****@*****.**", BirthDate = new DateTime(1982, 02, 01), Gender = Gender.Female, PhotoPath = "images/rosita.png", IsDeleted = false, WorkingHours = 1600.0, Role = Role.LECTURER }; Lecturer masha = new Lecturer { FirstName = "Masha", LastName = "Glizina", Email = "*****@*****.**", BirthDate = new DateTime(1990, 01, 01), Gender = Gender.Female, PhotoPath = "images/masha.jpg", IsDeleted = false, WorkingHours = 1600.0, Role = Role.LECTURER }; Lecturer lolita = new Lecturer { FirstName = "Lolita", LastName = "Baum", Email = "*****@*****.**", BirthDate = new DateTime(1975, 06, 07), Gender = Gender.Female, PhotoPath = "images/lolita.jpg", IsDeleted = false, WorkingHours = 800.0, Role = Role.LECTURER }; Lecturer bob = new Lecturer { FirstName = "Bob", LastName = "Pelle", Email = "*****@*****.**", BirthDate = new DateTime(1989, 02, 01), Gender = Gender.Male, PhotoPath = "images/bob.png", IsDeleted = false, WorkingHours = 900.0, Role = Role.LECTURER }; Lecturer bombo = new Lecturer { FirstName = "Bombo", LastName = "Park", Email = "*****@*****.**", BirthDate = new DateTime(1988, 08, 15), Gender = Gender.Male, PhotoPath = "images/bombo.jpg", IsDeleted = false, WorkingHours = 1600.0, Role = Role.LECTURER }; Lecturer chris = new Lecturer { FirstName = "Christopher", LastName = "Moser", Email = "*****@*****.**", BirthDate = new DateTime(1996, 09, 01), Gender = Gender.Male, PhotoPath = "images/christopher.png", IsDeleted = false, WorkingHours = 1700.0, Role = Role.STUDY_DIRECTOR }; Lecturer alic = new Lecturer { FirstName = "Alic", LastName = "Boldwin", Email = "*****@*****.**", BirthDate = new DateTime(1956, 03, 14), Gender = Gender.Male, PhotoPath = "images/alic.jpg", IsDeleted = false, WorkingHours = 1700.0, Role = Role.LECTURER }; Lecturer misha = new Lecturer { FirstName = "Mihail", LastName = "Patapovic", Email = "*****@*****.**", BirthDate = new DateTime(1983, 06, 12), Gender = Gender.Male, PhotoPath = "images/mihail.jpg", IsDeleted = false, WorkingHours = 850.0, Role = Role.LECTURER }; Lecturer kai = new Lecturer { FirstName = "Kai", LastName = "Bublik", Email = "*****@*****.**", BirthDate = new DateTime(1965, 02, 01), Gender = Gender.Male, PhotoPath = "images/Kai.jpg", IsDeleted = false, WorkingHours = 1200.0, Role = Role.LECTURER }; context.Lecturers.AddRange(margo, misha, kai, rosita, alic, chris, bombo, bob, masha); context.SaveChanges(); Lecturer l2 = new Lecturer { FirstName = "Mike", LastName = "White", Email = "*****@*****.**", BirthDate = new DateTime(1983, 04, 11), Gender = Gender.Female, PhotoPath = "images/mike.jpg", IsDeleted = false, WorkingHours = 1600.0, Role = Role.LECTURER }; l2.LecturersModules = new List <LecturerModule> { new LecturerModule { Lecturer = l2, Module = m12 }, new LecturerModule { Lecturer = l2, Module = m6 } }; // try to make seed data in other way => works! var michele = new Lecturer { FirstName = "Michele", LastName = "Orsi", Email = "*****@*****.**", BirthDate = new DateTime(1986, 05, 11), Gender = Gender.Male, PhotoPath = "images/michele.jpg", IsDeleted = false, WorkingHours = 1700.0, Role = Role.LECTURER }; var csbasics = new Module { Title = "Computer Science Basics", Code = "BTI1021", ECTS = 4, LectPerWeek = 4, TotalHours = 200 }; michele.LecturersModules = new List <LecturerModule> { new LecturerModule { Lecturer = michele, Module = csbasics }, new LecturerModule { Lecturer = michele, Module = m6 } }; aacol.Add(a1); michele.AdditionalAssignments = aacol; context.Lecturers.AddRange(michele, l2); context.SaveChanges(); //seed data for semester Semester s1 = new Semester { Code = "2020-2021 - FS", Date = new DateTime(2021, 02, 15), AdditionalAssignments = aacol, LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = masha }, new LecturerSemester { Lecturer = misha } } }; Semester s2 = new Semester { Code = "2020-2021 - HS", Date = new DateTime(2021, 08, 15), AdditionalAssignments = new List <AdditionalAssignment> { new AdditionalAssignment { Title = "newAdditionalAssigment1", AAHours = 0 }, new AdditionalAssignment { Title = "newAddtitonalAssigment2", AAHours = 0 } }, LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = margo }, new LecturerSemester { Lecturer = alic } } }; Semester s3 = new Semester { Code = "2021-2022 - FS", Date = new DateTime(2021, 02, 15), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = rosita }, new LecturerSemester { Lecturer = kai } } }; Semester s4 = new Semester { Code = "2021-2022 - HS", Date = new DateTime(2021, 08, 13), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = margo }, new LecturerSemester { Lecturer = alic } } }; Semester as_23_24 = new Semester() { Code = "2023-2024 - HS", Date = new DateTime(2021, 08, 13), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = margo }, new LecturerSemester { Lecturer = alic } } }; Semester ss_24 = new Semester() { Code = "2025 - FS", Date = new DateTime(2024, 08, 13), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = margo }, new LecturerSemester { Lecturer = alic } } }; Semester as_24_25 = new Semester() { Code = "2024-2025 - HS", Date = new DateTime(2024, 08, 13), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = margo }, new LecturerSemester { Lecturer = michele } } }; Semester ss_25 = new Semester() { Code = "2025 - FS", Date = new DateTime(2025, 08, 13), LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Lecturer = michele }, new LecturerSemester { Lecturer = alic } } }; s2.ModuleRuns = new HashSet <ModuleRun> { new ModuleRun { Code = "a", SemesterId = s2.SemesterId, Module = csbasics, Place = "Biel", LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = michele }, new LecturerModuleRun { Lecturer = l2 } } }, new ModuleRun { Code = "q", SemesterId = s3.SemesterId, Place = "Bern", Module = projectAndTraining1 }, new ModuleRun { Code = "b", SemesterId = s2.SemesterId, Module = csbasics, Place = "Biel", LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = michele }, new LecturerModuleRun { Lecturer = l2 } } } }; lmr.Lecturer = michele; lmrcol.Add(lmr); s2.LecturersSemesters = new List <LecturerSemester> { new LecturerSemester { Semester = s2, Lecturer = michele }, new LecturerSemester { Semester = s2, Lecturer = l2 } }; context.Semesters.AddRange(s1, s2, s3, s4, as_23_24, ss_24, as_24_25, ss_25); context.SaveChanges(); //seed data for module run ModuleRun p_ucd = new ModuleRun { Code = "p", Module = m2, SemesterId = s3.SemesterId }; ModuleRun q_ucd = new ModuleRun { Code = "q", Module = m2, SemesterId = s1.SemesterId }; ModuleRun c = new ModuleRun { Code = "a", Module = m6, SemesterId = s2.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = misha } } }; ModuleRun mr2 = new ModuleRun { Code = "a", ModuleId = context.Modules.Single(s => s.Code == "BTI7302").ModuleId, SemesterId = context.Semesters.Single(b => b.Code == "2021-2022 - HS").SemesterId }; context.ModuleRuns.AddRange(mr2); context.SaveChanges(); mrcol.Add(mr2); context.SaveChanges(); ModuleRun project2MR = new ModuleRun { Module = project2, SemesterId = s4.SemesterId, LecturersMR = lmrcol, Place = "Biel", Code = "b" }; ModuleRun computing_project_bi24 = new ModuleRun { Module = computing_project, SemesterId = as_24_25.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = margo }, new LecturerModuleRun { Lecturer = masha } }, Place = "Biel", Code = "a/b" }; ModuleRun intro_multim_bi23 = new ModuleRun { Module = intro_multim, SemesterId = as_23_24.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = kai }, new LecturerModuleRun { Lecturer = misha } }, Place = "Biel", Code = "a/b" }; ModuleRun prof_skills_bi24 = new ModuleRun { Module = prof_skills, SemesterId = ss_24.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = lolita }, new LecturerModuleRun { Lecturer = rosita } }, Place = "Biel", Code = "a/b" }; ModuleRun prof_skills_bi25 = new ModuleRun { Module = prof_skills, SemesterId = ss_25.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = lolita }, new LecturerModuleRun { Lecturer = rosita } }, Place = "Biel", Code = "a/b" }; ModuleRun computing_project_be24 = new ModuleRun { Module = computing_project, SemesterId = as_24_25.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = margo }, new LecturerModuleRun { Lecturer = masha } }, Place = "Bern", Code = "p/q" }; ModuleRun intro_multim_be23 = new ModuleRun { Module = intro_multim, SemesterId = as_23_24.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = kai }, new LecturerModuleRun { Lecturer = misha } }, Place = "Bern", Code = "p/q" }; ModuleRun prof_skills_be24 = new ModuleRun { Module = prof_skills, SemesterId = ss_24.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = lolita }, new LecturerModuleRun { Lecturer = rosita } }, Place = "Bern", Code = "p/q" }; ModuleRun prof_skills_be25 = new ModuleRun { Module = prof_skills, SemesterId = ss_25.SemesterId, LecturersMR = new List <LecturerModuleRun> { new LecturerModuleRun { Lecturer = lolita }, new LecturerModuleRun { Lecturer = rosita } }, Place = "Bern", Code = "p/q" }; context.ModuleRuns.AddRange(project2MR, c, q_ucd, p_ucd, prof_skills_bi24, prof_skills_bi25, intro_multim_bi23, computing_project_bi24, prof_skills_be24, prof_skills_be25, intro_multim_be23, computing_project_be24); context.SaveChanges(); //seed data for StudyBranch StudyBranch it = new StudyBranch { Code = "TI", Title = "Information Technology", Modules = new List <Module> { project2, m2, m3, m4, m5, m6, m7, m8, m9, databases, m12, csbasics, studienBeratung } }; context.StudyBranches.Add(it); context.SaveChanges(); //seed data for plan Plan plan23_24 = new Plan { Year = "2023-2024", AutumnSemester = as_23_24, SpringSemester = ss_24 //Semesters= new List<Semester> { as_23_24,ss_24} }; Plan plan24_25 = new Plan { Year = "2024-2025", AutumnSemester = as_24_25, SpringSemester = ss_25 }; context.Plans.Add(plan23_24); context.Plans.Add(plan24_25); context.SaveChanges(); // seed plan-->planlecturers PlanLecturer pl01 = new PlanLecturer { PlanId = 1, LecturerId = 1 }; PlanLecturer pl2 = new PlanLecturer { PlanId = 1, LecturerId = 2 }; PlanLecturer pl3 = new PlanLecturer { PlanId = 2, LecturerId = 3 }; PlanLecturer pl4 = new PlanLecturer { PlanId = 2, LecturerId = 4 }; PlanLecturer pl5 = new PlanLecturer { PlanId = 1, LecturerId = 5 }; PlanLecturer pl6 = new PlanLecturer { PlanId = 1, LecturerId = 6 }; PlanLecturer pl7 = new PlanLecturer { PlanId = 2, LecturerId = 7 }; PlanLecturer pl8 = new PlanLecturer { PlanId = 2, LecturerId = 8 }; PlanLecturer pl9 = new PlanLecturer { PlanId = 1, LecturerId = 9 }; PlanLecturer pl10 = new PlanLecturer { PlanId = 1, LecturerId = 10 }; PlanLecturer pl11 = new PlanLecturer { PlanId = 2, LecturerId = 11 }; PlanLecturer pl12 = new PlanLecturer { PlanId = 2, LecturerId = 12 }; PlanLecturer pl011 = new PlanLecturer { PlanId = 2, LecturerId = 1 }; PlanLecturer pl21 = new PlanLecturer { PlanId = 2, LecturerId = 2 }; PlanLecturer pl31 = new PlanLecturer { PlanId = 1, LecturerId = 3 }; PlanLecturer pl41 = new PlanLecturer { PlanId = 1, LecturerId = 4 }; PlanLecturer pl51 = new PlanLecturer { PlanId = 2, LecturerId = 5 }; PlanLecturer pl61 = new PlanLecturer { PlanId = 2, LecturerId = 6 }; PlanLecturer pl71 = new PlanLecturer { PlanId = 1, LecturerId = 7 }; PlanLecturer pl81 = new PlanLecturer { PlanId = 1, LecturerId = 8 }; PlanLecturer pl91 = new PlanLecturer { PlanId = 2, LecturerId = 9 }; PlanLecturer pl101 = new PlanLecturer { PlanId = 2, LecturerId = 10 }; PlanLecturer pl111 = new PlanLecturer { PlanId = 1, LecturerId = 11 }; PlanLecturer pl121 = new PlanLecturer { PlanId = 1, LecturerId = 12 }; context.PlanLecturers.AddRange(pl01, pl2, pl3, pl4, pl5, pl6, pl7, pl8, pl9, pl10, pl11, pl12, pl011, pl011, pl21, pl31, pl41, pl51, pl61, pl71, pl81, pl91, pl101, pl111, pl121); context.SaveChanges(); // PlanLecturer newPlanLecturer = new PlanLecturer(); //List<PlanLecturer> planLecturers = new List<PlanLecturer>(); //foreach (var p in context.Plans) { // foreach (var l in context.Lecturers) // { // int id1 = l.Id; // int id2 = p.Id; // newPlanLecturer = new PlanLecturer() { LecturerId = id1, PlanId = id2 }; // //planLecturers.Add(newPlanLecturer); // context.PlanLecturers.Add(new PlanLecturer()); // } //} ////context.PlanLecturers.AddRange(planLecturer1, planLecturer2, planLecturer3, planLecturer4); //context.SaveChanges(); } }