public void Salvar(Aluno aluno) { if (aluno.Id > 0) Alterar(aluno); else Inserir(aluno); }
public ActionResult Cadastrar(Aluno aluno) { if (ModelState.IsValid) { var appAluno = new AlunoAplicacao(); appAluno.Salvar(aluno); return RedirectToAction("Index"); } return View(aluno); }
public void Alterar(Aluno aluno) { var strQuery = string.Format("UPDATE Aluno SET Nome = '{0}' , Mae = '{1}' , DataNascimento = '{2}' WHERE AlunoId = {3}", aluno.Nome, aluno.Mae, aluno.DataNascimento, aluno.Id); using (contexto = new Contexto()) { contexto.ExecutaComando(strQuery); } }
public void Inserir(Aluno aluno) { string strQuery = string.Format("INSERT INTO Aluno (Nome,Mae,DataNascimento) VALUES ('{0}','{1}','{2}')", aluno.Nome, aluno.Mae, aluno.DataNascimento); using (contexto = new Contexto()) { contexto.ExecutaComando(strQuery); } }
public void Salvar(Aluno aluno) { repositorio.Salvar(aluno); }