예제 #1
0
        private void AtualizarCursosInstrutor(string[] cursosSelecionados, Instrutor instrutorAtualizado)
        {
            if (cursosSelecionados == null)
            {
                instrutorAtualizado.CursoInstrutores = new List <CursoInstrutor>();
                return;
            }

            var cursosSelct       = new HashSet <string>(cursosSelecionados);
            var cursosInstrutores = new HashSet <int>(instrutorAtualizado.CursoInstrutores.Select(c => c.Curso.CursoId));

            foreach (var curso in Contexto.Cursos)
            {
                if (cursosSelct.Contains(curso.CursoId.ToString()))
                {
                    if (!cursosInstrutores.Contains(curso.CursoId))
                    {
                        instrutorAtualizado.CursoInstrutores.Add(new CursoInstrutor {
                            InstrutorId = instrutorAtualizado.Id, CursoId = curso.CursoId
                        });
                    }
                }
                else
                {
                    if (cursosInstrutores.Contains(curso.CursoId))
                    {
                        CursoInstrutor cursoRemover = instrutorAtualizado.CursoInstrutores.FirstOrDefault(x => x.CursoId == curso.CursoId);
                        Contexto.Remove(cursoRemover);
                    }
                }
            }
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Nome,Sobrenome,Contratacao, Escritorio")] Instrutor instrutor, string[] cursosSelecionados)
        {
            if (cursosSelecionados != null)
            {
                instrutor.CursosInstrutor = new List <CursoInstrutor>();
                foreach (var curso in cursosSelecionados)
                {
                    var cursoToAdd = new CursoInstrutor {
                        InstrutorID = instrutor.InstrutorID, CursoID = int.Parse(curso)
                    };
                    instrutor.CursosInstrutor.Add(cursoToAdd);
                }
            }

            if (ModelState.IsValid)
            {
                _context.Add(instrutor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            CarregarCursosAtribuidos(instrutor);

            return(View(instrutor));
        }
예제 #3
0
        private void AtualizarCursosInstrutor(string[] cursosSelecionados, Instrutor instrutorToUpdate)
        {
            if (cursosSelecionados == null)
            {
                instrutorToUpdate.CursosInstrutor = new List <CursoInstrutor>();
                return;
            }

            var cursosSelecionadosHS = new HashSet <string>(cursosSelecionados);
            var CursosInstrutor      = new HashSet <int>
                                           (instrutorToUpdate.CursosInstrutor.Select(c => c.Curso.CursoID));

            foreach (var curso in _context.Curso)
            {
                if (cursosSelecionadosHS.Contains(curso.CursoID.ToString()))
                {
                    if (!CursosInstrutor.Contains(curso.CursoID))
                    {
                        instrutorToUpdate.CursosInstrutor.Add(new CursoInstrutor
                        {
                            InstrutorID = instrutorToUpdate.InstrutorID,
                            CursoID     = curso.CursoID
                        });
                    }
                }
                else
                {
                    if (CursosInstrutor.Contains(curso.CursoID))
                    {
                        CursoInstrutor cursoToRemove = instrutorToUpdate.CursosInstrutor.FirstOrDefault(i => i.CursoID == curso.CursoID);
                        _context.Remove(cursoToRemove);
                    }
                }
            }
        }
예제 #4
0
        public async Task <IActionResult> Criar([Bind("Nome, Sobrenome, DataContratacao, CursoInstrutores")] Instrutor instrutor, string[] cursosSelecionados)
        {
            if (cursosSelecionados != null)
            {
                instrutor.CursoInstrutores = new List <CursoInstrutor>();
                foreach (var curso in cursosSelecionados)
                {
                    var cursoAdicionar = new CursoInstrutor {
                        InstrutorId = instrutor.Id, CursoId = int.Parse(curso)
                    };
                    instrutor.CursoInstrutores.Add(cursoAdicionar);
                }
            }
            if (ModelState.IsValid)
            {
                Contexto.Add(instrutor);
                await Contexto.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            DataAssinaturaCurso(instrutor);
            return(View(instrutor));
        }
예제 #5
0
        public static void Inicializador(Contexto contexto)
        {
            contexto.Database.EnsureCreated();
            Console.Write("Entrou");
            if (contexto.Estudantes.Any())
            {
                Console.WriteLine("Saiu");
                return; // O banco esta populado
            }

            var estudantes = new Estudante[]
            {
                new Estudante {
                    Nome = "Carson", Sobrenome = "Alexander", EnrollmentDate = DateTime.Parse("2010-09-01")
                },
                new Estudante {
                    Nome = "Meredith", Sobrenome = "Alonso", EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Estudante {
                    Nome = "Arturo", Sobrenome = "Anand", EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Estudante {
                    Nome = "Gytis", Sobrenome = "Barzdukas", EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Estudante {
                    Nome = "Yan", Sobrenome = "Li", EnrollmentDate = DateTime.Parse("2012-09-01")
                },
                new Estudante {
                    Nome = "Peggy", Sobrenome = "Justice", EnrollmentDate = DateTime.Parse("2011-09-01")
                },
                new Estudante {
                    Nome = "Laura", Sobrenome = "Norman", EnrollmentDate = DateTime.Parse("2013-09-01")
                },
                new Estudante {
                    Nome = "Nino", Sobrenome = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01")
                }
            };

            foreach (var estudante in estudantes)
            {
                contexto.Estudantes.Add(estudante);
            }
            contexto.SaveChanges();

            var instrutores = new Instrutor[]
            {
                new Instrutor {
                    Nome            = "Kim", Sobrenome = "Abercrombie",
                    DataContratacao = DateTime.Parse("1995-03-11")
                },
                new Instrutor {
                    Nome            = "Fadi", Sobrenome = "Fakhouri",
                    DataContratacao = DateTime.Parse("2002-07-06")
                },
                new Instrutor {
                    Nome            = "Roger", Sobrenome = "Harui",
                    DataContratacao = DateTime.Parse("1998-07-01")
                },
                new Instrutor {
                    Nome            = "Candace", Sobrenome = "Kapoor",
                    DataContratacao = DateTime.Parse("2001-01-15")
                },
                new Instrutor {
                    Nome            = "Roger", Sobrenome = "Zheng",
                    DataContratacao = DateTime.Parse("2004-02-12")
                }
            };

            foreach (Instrutor i in instrutores)
            {
                contexto.Instrutores.Add(i);
            }
            contexto.SaveChanges();



            var departments = new Departamento[]
            {
                new Departamento {
                    Nome = "English", Orcamento = 350000, DataInicio = DateTime.Parse("2007-09-01"), InstrutorId = instrutores.Single(i => i.Sobrenome == "Abercrombie").Id
                },
                new Departamento {
                    Nome = "Mathematics", Orcamento = 100000, DataInicio = DateTime.Parse("2007-09-01"), InstrutorId = instrutores.Single(i => i.Sobrenome == "Fakhouri").Id
                },
                new Departamento {
                    Nome = "Engineering", Orcamento = 350000, DataInicio = DateTime.Parse("2007-09-01"), InstrutorId = instrutores.Single(i => i.Sobrenome == "Harui").Id
                },
                new Departamento {
                    Nome = "Economics", Orcamento = 100000, DataInicio = DateTime.Parse("2007-09-01"), InstrutorId = instrutores.Single(i => i.Sobrenome == "Kapoor").Id
                }
            };

            foreach (Departamento d in departments)
            {
                contexto.Departamentos.Add(d);
            }
            contexto.SaveChanges();

            var courses = new Curso[]
            {
                new Curso {
                    CursoId        = 1050, Titulo = "Chemistry", Creditos = 3,
                    DepartamentoId = departments.Single(s => s.Nome == "Engineering").DepartamentoId
                },
                new Curso {
                    CursoId        = 4022, Titulo = "Microeconomics", Creditos = 3,
                    DepartamentoId = departments.Single(s => s.Nome == "Economics").DepartamentoId
                },
                new Curso {
                    CursoId        = 4041, Titulo = "Macroeconomics", Creditos = 3,
                    DepartamentoId = departments.Single(s => s.Nome == "Economics").DepartamentoId
                },
                new Curso {
                    CursoId        = 1045, Titulo = "Calculus", Creditos = 4,
                    DepartamentoId = departments.Single(s => s.Nome == "Mathematics").DepartamentoId
                },
                new Curso {
                    CursoId        = 3141, Titulo = "Trigonometry", Creditos = 4,
                    DepartamentoId = departments.Single(s => s.Nome == "Mathematics").DepartamentoId
                },
                new Curso {
                    CursoId        = 2021, Titulo = "Composition", Creditos = 3,
                    DepartamentoId = departments.Single(s => s.Nome == "English").DepartamentoId
                },
                new Curso {
                    CursoId        = 2042, Titulo = "Literature", Creditos = 4,
                    DepartamentoId = departments.Single(s => s.Nome == "English").DepartamentoId
                },
            };

            foreach (Curso c in courses)
            {
                contexto.Cursos.Add(c);
            }
            contexto.SaveChanges();

            var officeAssignments = new Escritorio[]
            {
                new Escritorio {
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Fakhouri").Id,
                    Localizacao = "Smith 17"
                },
                new Escritorio {
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Harui").Id,
                    Localizacao = "Gowan 27"
                },
                new Escritorio {
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Kapoor").Id,
                    Localizacao = "Thompson 304"
                },
            };

            foreach (Escritorio o in officeAssignments)
            {
                contexto.Escritorios.Add(o);
            }
            contexto.SaveChanges();

            var courseInstructors = new CursoInstrutor[]
            {
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Chemistry").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Kapoor").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Chemistry").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Harui").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Microeconomics").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Zheng").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Macroeconomics").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Zheng").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Calculus").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Fakhouri").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Trigonometry").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Harui").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Composition").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Abercrombie").Id
                },
                new CursoInstrutor {
                    CursoId     = courses.Single(c => c.Titulo == "Literature").CursoId,
                    InstrutorId = instrutores.Single(i => i.Sobrenome == "Abercrombie").Id
                },
            };

            foreach (CursoInstrutor ci in courseInstructors)
            {
                contexto.CursoInstrutores.Add(ci);
            }
            contexto.SaveChanges();

            var enrollments = new CursoEstudante[]
            {
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alexander").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Chemistry").CursoId,
                    Grade       = Grades.A
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alexander").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Microeconomics").CursoId,
                    Grade       = Grades.C
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alexander").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Macroeconomics").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alonso").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Calculus").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alonso").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Trigonometry").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Alonso").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Composition").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Anand").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Chemistry").CursoId
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Anand").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Microeconomics").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Barzdukas").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Chemistry").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Li").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Composition").CursoId,
                    Grade       = Grades.B
                },
                new CursoEstudante {
                    EstudanteId = estudantes.Single(s => s.Sobrenome == "Justice").Id,
                    CursoID     = courses.Single(c => c.Titulo == "Literature").CursoId,
                    Grade       = Grades.B
                }
            };

            foreach (CursoEstudante e in enrollments)
            {
                var enrollmentInDataBase = contexto.CursoEstudantes.Where(
                    s =>
                    s.Estudante.Id == e.EstudanteId &&
                    s.Curso.CursoId == e.CursoID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    contexto.CursoEstudantes.Add(e);
                }
            }
            contexto.SaveChanges();
        }
예제 #6
0
        public static void Initialize(IServiceProvider serviceProvider)

        {
            using (var context = new WebEscolaContext(

                       serviceProvider.GetRequiredService <

                           DbContextOptions <WebEscolaContext> >()))

            {
                context.Database.EnsureCreated();


                if (context.Aluno.Any())

                {
                    return;
                }


                var alunos = new Aluno[]

                {
                    new Aluno {
                        Nome = "Alberto", Sobrenome = "Almeida", Data = DateTime.Parse("1970-09-21")
                    },

                    new Aluno {
                        Nome = "Marcelo", Sobrenome = "Barros", Data = DateTime.Parse("2001-04-07")
                    },

                    new Aluno {
                        Nome = "Henrique", Sobrenome = "Carvalho", Data = DateTime.Parse("1994-12-10")
                    },

                    new Aluno {
                        Nome = "Daniel", Sobrenome = "Freitas", Data = DateTime.Parse("1974-02-01")
                    },

                    new Aluno {
                        Nome = "Fábio", Sobrenome = "Henrique", Data = DateTime.Parse("1978-07-10")
                    },

                    new Aluno {
                        Nome = "Fernanda", Sobrenome = "Machado", Data = DateTime.Parse("1994-12-15")
                    },

                    new Aluno {
                        Nome = "Cristina", Sobrenome = "Miranda", Data = DateTime.Parse("2003-09-01")
                    },

                    new Aluno {
                        Nome = "Roberto", Sobrenome = "Santos", Data = DateTime.Parse("1998-03-17")
                    }
                };

                foreach (Aluno a in alunos)

                {
                    context.Aluno.Add(a);
                }

                context.SaveChanges();


                var instrutores = new Instrutor[]

                {
                    new Instrutor {
                        Nome = "João", Sobrenome = "Miguel", Contratacao = DateTime.Parse("2015-02-5")
                    },

                    new Instrutor {
                        Nome = "Maria", Sobrenome = "Cecilia", Contratacao = DateTime.Parse("2017-03-10")
                    },

                    new Instrutor {
                        Nome = "Ana", Sobrenome = "Julia", Contratacao = DateTime.Parse("2013-4-15")
                    },

                    new Instrutor {
                        Nome = "Davi", Sobrenome = "Lucas", Contratacao = DateTime.Parse("2019-05-20")
                    },

                    new Instrutor {
                        Nome = "Laura", Sobrenome = "Neves", Contratacao = DateTime.Parse("2020-01-25")
                    }
                };

                foreach (Instrutor i in instrutores)

                {
                    context.Instrutor.Add(i);
                }

                context.SaveChanges();


                var departamentos = new Departamento[]

                {
                    new Departamento {
                        Nome = "Treinamento", Orcamento = 100000, Inicio = DateTime.Parse("1993-09-25"),

                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Julia").InstrutorID
                    },

                    new Departamento {
                        Nome = "Desenvolvimento", Orcamento = 250000, Inicio = DateTime.Parse("1993-09-25"),

                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Neves").InstrutorID
                    },

                    new Departamento {
                        Nome = "Consultoria", Orcamento = 50000, Inicio = DateTime.Parse("1993-09-25"),

                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Lucas").InstrutorID
                    }
                };

                foreach (Departamento d in departamentos)

                {
                    context.Departamento.Add(d);
                }

                context.SaveChanges();


                var cursos = new Curso[]

                {
                    new Curso {
                        Titulo = "Blazor Avançado", Credito = 4,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Consultoria").DepartamentoID
                    },

                    new Curso {
                        Titulo = "Blazor", Credito = 3,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Consultoria").DepartamentoID
                    },

                    new Curso {
                        Titulo = "ASP NET Core - API e SignalR", Credito = 4,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Consultoria").DepartamentoID
                    },

                    new Curso {
                        Titulo = "ASP NET Core MVC Avançado", Credito = 4,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Desenvolvimento").DepartamentoID
                    },

                    new Curso {
                        Titulo = "ASP NET Core MVC", Credito = 3,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Treinamento").DepartamentoID
                    },

                    new Curso {
                        Titulo = "ASP NET Core", Credito = 2,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Treinamento").DepartamentoID
                    },

                    new Curso {
                        Titulo = "C# básico", Credito = 1,

                        DepartamentoID = departamentos.Single(s => s.Nome == "Treinamento").DepartamentoID
                    }
                };

                foreach (Curso c in cursos)

                {
                    context.Curso.Add(c);
                }

                context.SaveChanges();


                var escritorios = new Escritorio[]

                {
                    new Escritorio {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Julia").InstrutorID,

                        Localizacao = "Paulista"
                    },

                    new Escritorio {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Neves").InstrutorID,

                        Localizacao = "Berrini"
                    },

                    new Escritorio {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Lucas").InstrutorID,

                        Localizacao = "Faria Lima"
                    }
                };


                foreach (Escritorio e in escritorios)

                {
                    context.Escritorio.Add(e);
                }

                context.SaveChanges();


                var cursosInstrutor = new CursoInstrutor[]

                {
                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Miguel").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "C# básico").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Cecilia").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "ASP NET Core").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Cecilia").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "ASP NET Core MVC").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Cecilia").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "ASP NET Core MVC Avançado").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Julia").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "ASP NET Core - API e SignalR").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Lucas").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "Blazor").CursoID
                    },

                    new CursoInstrutor {
                        InstrutorID = instrutores.Single(i => i.Sobrenome == "Lucas").InstrutorID,

                        CursoID = cursos.Single(i => i.Titulo == "Blazor Avançado").CursoID
                    }
                };

                foreach (CursoInstrutor ci in cursosInstrutor)

                {
                    context.CursoInstrutor.Add(ci);
                }

                context.SaveChanges();


                var matriculas = new Matricula[]

                {
                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Almeida").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "C# básico").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Almeida").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Almeida").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Barros").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Barros").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Barros").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "Blazor").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Carvalho").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Carvalho").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Carvalho").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC Avançado").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Carvalho").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core - API e SignalR").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Freitas").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "Blazor").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Freitas").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "Blazor Avançado").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Henrique").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Machado").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core MVC Avançado").CursoID
                    },

                    new Matricula {
                        AlunoID = alunos.Single(i => i.Sobrenome == "Miranda").AlunoID,

                        CursoID = cursos.Single(c => c.Titulo == "ASP NET Core").CursoID
                    },
                };

                foreach (Matricula m in matriculas)

                {
                    context.Matricula.Add(m);
                }

                context.SaveChanges();
            }
        }