public void Salvar(Aluno aluno)
 {
     if (aluno.Id > 0)
         Alterar(aluno);
     else
         Inserir(aluno);
 }
 public ActionResult Editar(Aluno aluno)
 {
     if (ModelState.IsValid)
     {
         appAluno.Salvar(aluno);
         return RedirectToAction("Index");
     }
     return View(aluno);
 }
 public ActionResult Cadastrar(Aluno aluno)
 {
     if (ModelState.IsValid)
     {
         var appAluno = new AlunoAplicacao();
         appAluno.Salvar(aluno);
         return RedirectToAction("Index");
     }
     return View(aluno);
 }
 private void Inserir(Aluno aluno)
 {
     var strQuery = "";
     strQuery += " INSERT INTO ALUNO (Nome, Mae, DataNascimento) ";
     strQuery += string.Format(" VALUES ('{0}','{1}','{2}') ",
         aluno.Nome, aluno.Mae, aluno.DataNascimento
         );
     using (contexto = new Contexto())
     {
         contexto.ExecutaComando(strQuery);
     }
 }
 private void Alterar(Aluno aluno)
 {
     var strQuery = "";
     strQuery += " UPDATE ALUNO SET ";
     strQuery += string.Format(" Nome = '{0}', ", aluno.Nome);
     strQuery += string.Format(" Mae = '{0}', ", aluno.Mae);
     strQuery += string.Format(" DataNascimento = '{0}' ", aluno.DataNascimento);
     strQuery += string.Format(" WHERE AlunoId = {0} ", aluno.Id);
     using (contexto = new Contexto())
     {
         contexto.ExecutaComando(strQuery);
     }
 }
 private List<Aluno> TransformaReaderEmListaDeObjeto(SqlDataReader reader)
 {
     var alunos = new List<Aluno>();
     while (reader.Read())
     {
         var temObjeto = new Aluno()
                             {
                                 Id = int.Parse(reader["AlunoId"].ToString()),
                                 Nome = reader["Nome"].ToString(),
                                 Mae = reader["Mae"].ToString(),
                                 DataNascimento = DateTime.Parse(reader["DataNascimento"].ToString())
                             };
         alunos.Add(temObjeto);
     }
     reader.Close();
     return alunos;
 }
 public void Salvar(Aluno aluno)
 {
     repositorio.Salvar(aluno);
 }
 public void Excluir(Aluno aluno)
 {
     repositorio.Excluir(aluno);
 }