示例#1
0
 public EnrollmentsController(UniversityAppContext context, IWebHostEnvironment hostEnvironment)
 {
     _context          = context;
     webHostEnviroment = hostEnvironment;
 }
示例#2
0
 public CoursesController(UniversityAppContext context)
 {
     _context = context;
 }
 public ProfessorsApiController(UniversityAppContext context)
 {
     _context = context;
 }
示例#4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new UniversityAppContext(
                       serviceProvider.GetRequiredService <DbContextOptions <UniversityAppContext> >()))
            {
                if (context.Student.Any() || context.Professor.Any() || context.Courses.Any() || context.Enrollment.Any())
                {
                    return;
                }

                context.Student.AddRange(
                    new Student {
                    StudentId = "25/2018", FirstName = "Stefan", LastName = "Simonovski", AcquiredCredits = 120, EducationLevel = "First Year", EnrollmentDate = DateTime.Parse("2018 - 9 - 3"), CurrentSemester = 3
                },
                    new Student {
                    StudentId = "56/2018", FirstName = "Mirko", LastName = "Mirkovski", AcquiredCredits = 100, EducationLevel = "First Year", EnrollmentDate = DateTime.Parse("2018 - 9 - 5"), CurrentSemester = 3
                }
                    );
                context.SaveChanges();

                context.Professor.AddRange(
                    new Professor {
                    FirstName = "Rob", LastName = "Bob", AcademicRank = "vonreden", Degree = "Magister", HireDate = DateTime.Parse("1961-11-19"), OfficeNumber = "12122"
                },
                    new Professor {
                    FirstName = "Bobby", LastName = "Robert", AcademicRank = "vonreden", Degree = "Doktor na nauki", HireDate = DateTime.Parse("1970-11- 30"), OfficeNumber = "32323"
                }
                    );
                context.SaveChanges();

                context.Courses.AddRange(
                    new Course
                {
                    Title             = "Matematika",
                    Credits           = 5,
                    Programme         = "Programa",
                    EducationLevel    = "Dificult",
                    Semester          = 1,
                    FirstProfessorId  = context.Professor.Single(d => d.FirstName == "Rob" && d.LastName == "Bob").Id,
                    SecondProfessorId = context.Professor.Single(d => d.FirstName == "Bobby" && d.LastName == "Robert").Id
                }

                    );
                context.SaveChanges();

                context.Student.AddRange(

                    new Student {
                    StudentId = "25/2018", FirstName = "Stefan", LastName = "Simonovski", AcquiredCredits = 120, EducationLevel = "First Year", EnrollmentDate = DateTime.Parse("2018 - 9 - 3"), CurrentSemester = 3
                },
                    new Student {
                    StudentId = "56/2018", FirstName = "Mirko", LastName = "Mirkovski", AcquiredCredits = 100, EducationLevel = "First Year", EnrollmentDate = DateTime.Parse("2018 - 9 - 5"), CurrentSemester = 3
                }

                    );
                context.SaveChanges();

                context.Enrollment.AddRange(
                    new Enrollment {
                    CourseId = context.Courses.Single(c => c.Title == "Matematika").Id, StudentId = context.Student.Single(s => s.FirstName == "Stefan" && s.LastName == "Simonovski").Id, ExamPoints = 56, AdditionalPoint = 15, ProjectPoints = 23, SeminarPoints = 15, Year = 2020, Grade = 7, FinishDate = DateTime.Parse("2020 - 5 - 26")
                },
                    new Enrollment {
                    CourseId = context.Courses.Single(c => c.Title == "Matematika").Id, StudentId = context.Student.Single(s => s.FirstName == "Mirko" && s.LastName == "Mirkovski").Id, ExamPoints = 70, AdditionalPoint = 15, ProjectPoints = 25, SeminarPoints = 15, Year = 2020, Grade = 8, FinishDate = DateTime.Parse("2020 - 5 - 26")
                }
                    );

                //context.Enrollment.AddRange(
                //    new Enrollment { CourseId = 1, StudentId = 1, ExamPoints = 56, AdditionalPoint = 15, ProjectPoints = 23, SeminarPoints = 15, Year = 2020, Grade = 7, FinishDate = DateTime.Parse("2020 - 5 - 26") },
                //    new Enrollment { CourseId = 1, StudentId = 2, ExamPoints = 70, AdditionalPoint = 15, ProjectPoints = 25, SeminarPoints = 15, Year = 2020, Grade = 8, FinishDate = DateTime.Parse("2020 - 5 - 26") }
                //    );

                context.SaveChanges();

                //       var enrollments = new Enrollment[]
                //{
                //   new Enrollment{StudentId=1,CourseId=2, ExamPoints = 56, AdditionalPoint = 15, ProjectPoints = 23, SeminarPoints = 15, Year = 2020, Grade = 7, FinishDate = DateTime.Parse("2020 - 5 - 26")},
                //   new Enrollment{StudentId=2,CourseId=2,ExamPoints = 70, AdditionalPoint = 15, ProjectPoints = 25, SeminarPoints = 15, Year = 2020, Grade = 8, FinishDate = DateTime.Parse("2020 - 5 - 26") },

                //};
                //       foreach (Enrollment e in enrollments)
                //       {
                //           context.Enrollment.Add(e);
                //       }
                //       context.SaveChanges();
            }
        }
 public StudentsController(UniversityAppContext context)
 {
     _context = context;
 }
 public EnrollmentsApiController(UniversityAppContext context)
 {
     _context = context;
 }