예제 #1
0
        public void Excluir(Matricula matricula)
        {
            var matriculaExcluida = _contexto.Matriculas.Find(matricula.MatriculaID);

            _contexto.Entry(matriculaExcluida).State = System.Data.Entity.EntityState.Deleted;
            _contexto.SaveChanges();
        }
예제 #2
0
        public void Adicionar(Matricula matricula)
        {
            matricula.DataMatricula = DateTime.Now;

            _contexto.Matriculas.Add(matricula);
            _contexto.SaveChanges();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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;
        }