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 Emprestimo SelecionarEmprestimoPorIdLivro(int idLivro)
 {
     try
     {
         dal = new DAL.EmprestimoDAL();
         return(dal.SelectEmprestimoByIdLivro(idLivro));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
        public void ExcluirLivro(Livro livro)
        {
            try
            {
                DAL.EmprestimoDAL dalEm = new DAL.EmprestimoDAL();

                if (dalEm.SelectEmprestimoByIdLivro(livro.IdLivro) != null)
                {
                    throw new Exception("O livro esta emprestado, nao e possivel excluir");
                }

                dal = new DAL.LivroDAL();
                dal.DeleteLivro(livro);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }