public ActionResult Adicionar(MatriculaViewModel matricula)
        {
            if(ModelState.IsValid)
            {
                try
                {
                    _matriculaRepositorio.Adicionar(Mapeamento.ViewModelToView.Matricula(matricula));
                    return RedirectToAction("Listar");
                }
                catch (Exception)
                {
                    InsereViewBagTurma();
                    return View();
                }
            }

            return View();
        }
Beispiel #2
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;
        }
        public ActionResult Excluir(MatriculaViewModel matricula)
        {
            try
            {
                _matriculaRepositorio.Excluir(Mapeamento.ViewModelToView.Matricula(matricula));
                return RedirectToAction("Listar");
            }
            catch
            {
                InsereViewBagAluno(matricula.MatriculaID);
                InsereViewBagTurma();

                return View(matricula.MatriculaID);
            }
        }