Example #1
0
        public Alunos Inserir(Alunos Aluno)
        {
            var ListaAlunos = this.ListaAlunos();
            var maxId       = ListaAlunos.Max(aluno => aluno.id);

            Aluno.id = maxId + 1;
            ListaAlunos.Add(Aluno);
            ReescreverArquivo(ListaAlunos);
            return(Aluno);
        }
Example #2
0
 public void Atualizar(Alunos aluno)
 {
     try
     {
         var alunoBD = new AlunoDAO();
         alunoBD.AtualizarAlunoDB(aluno);
     }
     catch (Exception ex)
     {
         throw new Exception($"Erro ao Atualizar Aluno: Erro => {ex.Message}");
     }
 }
Example #3
0
 public void Inserir(Alunos aluno)
 {
     try
     {
         var alunoBD = new AlunoDAO();
         alunoBD.InserirAlunoDB(aluno);
     }
     catch (Exception ex)
     {
         throw new Exception($"Erro ao Inserir Aluno: Erro => {ex.Message}");
     }
 }
Example #4
0
        public Alunos Atualizar(int id, Alunos Aluno)
        {
            var ListaAlunos = this.ListaAlunos();
            var itemIndex   = ListaAlunos.FindIndex(p => p.id == id);

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