public void Excluir(Matricula matricula) { var matriculaExcluida = _contexto.Matriculas.Find(matricula.MatriculaID); _contexto.Entry(matriculaExcluida).State = System.Data.Entity.EntityState.Deleted; _contexto.SaveChanges(); }
public void Adicionar(Matricula matricula) { matricula.DataMatricula = DateTime.Now; _contexto.Matriculas.Add(matricula); _contexto.SaveChanges(); }
public void Atualizar(Matricula matricula) { Matricula matriculaAlterada = _contexto.Matriculas.Find(matricula.MatriculaID); matriculaAlterada.AlunoID = matricula.AlunoID; matriculaAlterada.TurmaID = matricula.TurmaID; _contexto.Entry(matriculaAlterada).State = System.Data.Entity.EntityState.Modified; _contexto.SaveChanges(); }
public static Matricula Matricula(MatriculaViewModel matriculaViewModel) { Matricula _matricula = new Matricula() { MatriculaID = matriculaViewModel.MatriculaID, DataMatricula = matriculaViewModel.DataMatricula, AlunoID = matriculaViewModel.AlunoID, TurmaID = matriculaViewModel.TurmaID }; if (matriculaViewModel.Aluno != null) _matricula.Aluno = Aluno(matriculaViewModel.Aluno); if (matriculaViewModel.Turma != null) _matricula.Turma = Turma(matriculaViewModel.Turma); return _matricula; }