Esempio n. 1
0
        public void Atualizar(Aluno Aluno)
        {
            try
            {
                var alunoDB = new AlunoDAO();
                alunoDB.AtualizarAlunoBD(Aluno);
            }
            catch (Exception ex)
            {
                throw new Exception($"error ao atualizar aluno:error=>{ex.Message} ");
            }



            //var listaAlunos = this.ListarAluno();
            //var itemIndex = listaAlunos.FindIndex(p => p.id == id);

            //if (itemIndex >= 0)
            //{
            //	Aluno.id = id;
            //	listaAlunos[itemIndex] = Aluno;
            //}
            //else {
            //	return null;
            //}

            //ReescreverArquivo(listaAlunos);

            //return Aluno;
        }
Esempio n. 2
0
        public void Deletar(int id)
        {
            try
            {
                var alunoDB = new AlunoDAO();
                alunoDB.DeletarAlunoBD(id);
            }
            catch (Exception ex)
            {
                throw new Exception($"error ao deletar aluno:error=>{ex.Message} ");
            }
            //var listaAlunos = this.ListarAluno();
            //var itemIndex = listaAlunos.FindIndex(p => p.id == id);

            //if (itemIndex >= 0)
            //{

            //	listaAlunos.RemoveAt(itemIndex);
            //}
            //else
            //{
            //	return false;
            //}

            //ReescreverArquivo(listaAlunos);

            //return true;
        }
Esempio n. 3
0
 public List <Aluno> ListarAluno(int?id = null)
 {
     try
     {
         var alunoDB = new AlunoDAO();
         return(alunoDB.ListarAlunosBD(id));
     }
     catch (Exception ex)
     {
         throw new Exception($"error ao listar alunos:error=>{ex.Message} ");
     }
 }
Esempio n. 4
0
        public void Inserir(Aluno Aluno)
        {
            try
            {
                var alunoDB = new AlunoDAO();
                alunoDB.InserirAlunoBD(Aluno);
            }
            catch (Exception ex)
            {
                throw new Exception($"error ao inserir aluno:error=>{ex.Message} ");
            }


            //var listaAlunos = this.ListarAluno();

            //var maxId = listaAlunos.Max(aluno => aluno.id);
            //Aluno.id = maxId + 1;
            //listaAlunos.Add(Aluno);

            //ReescreverArquivo(listaAlunos);

            //return Aluno;
        }