public void IncluirEmprestimo(Emprestimo emprestimo)
        {
            try
            {
                DAL.LeitorDAL dalLe = new DAL.LeitorDAL();
                DAL.LivroDAL  dalLi = new DAL.LivroDAL();
                dal = new DAL.EmprestimoDAL();

                if (dal.SelectEmprestimoByIdLivro(emprestimo.IdLivro) != null)
                {
                    throw new Exception("Livro emprestado, emprestimo cancelado");
                }

                if (dal.SelectEmprestimosByIdLeitor(emprestimo.IdLeitor).Count >= 5)
                {
                    throw new Exception("Leitor ja atingiu o limite de livros, emprestimo cancelado");
                }

                dal.InsertEmprestimo(emprestimo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public List <Emprestimo> SelecionarEmprestimoPorIdLeitor(int idLeitor)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelectEmprestimosByIdLeitor(idLeitor));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        public void ExcluirLeitor(Leitor leitor)
        {
            try
            {
                DAL.EmprestimoDAL dalEm = new DAL.EmprestimoDAL();

                if (dalEm.SelectEmprestimosByIdLeitor(leitor.IdLeitor).Count > 0)
                {
                    throw new Exception("Leitor possui pendencias, Impossivel Exclui-lo");
                }

                dal = new DAL.LeitorDAL();
                dal.DeleteLeitor(leitor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }