public OperationResultSet <Book> GetAllBooks(string userName, string guid) { if (!CheckAuthenticated(userName, guid)) { return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.NotAuthenticated, "Please authenticate first!")); } using (BookData dataProvider = new BookData()) { try { Book[] result = dataProvider.GetAllBooks(); if (result == null) { return(new OperationResultSet <Book>(new List <Book>())); } return(new OperationResultSet <Book>(new List <Book>(result))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("BookManagement : GetAllBooks : " + ex.StackTrace); return(new OperationResultSet <Book>(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured")); } } }
public List <Book> GetAllBooks() { var list = new List <Book>(); using (var data = new BookData()) // se utiliza el using, para que al finalizar el garbage collection destruya el objeto { list = data.GetAllBooks(); // se consulta el metodo de la clase Bookdata }//al finalizar, cierra la conexion a la BD, entra por el dispose return(list); }
public List <BookEnt> GetAllBooks() { var list = new List <BookEnt>(); using (var data = new BookData()) { list = data.GetAllBooks(); } return(list); }