public IEnumerable <BookModel> List()
        {
            try
            {
                Logger.Trace("Begin => List");
                IEnumerable <Book> results = _bookRepository.List();

                if (results == null)
                {
                    Logger.Debug("No books found");
                    throw new HttpResponseException(HttpStatusCode.NoContent);
                }

                return(results.Select(t => BookModel.CopyFrom(t)));
            }
            catch (Exception err)
            {
                Logger.Error("Error in List", err);
                throw;
            }
            finally
            {
                Logger.Trace("End => List");
            }
        }
Exemple #2
0
        public BookModel Get(int bookId)
        {
            try
            {
                Logger.Trace("Begin => Get");
                Logger.DebugFormat("Parameters [bookId={0}]", bookId);

                Book result = _bookRepository.Get(bookId);

                if (result == null)
                {
                    Logger.DebugFormat("Book bookId={0} not found", bookId);
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                return(BookModel.CopyFrom(result));
            }
            catch (Exception err)
            {
                Logger.Error("Error in Get", err);
                throw;
            }
            finally
            {
                Logger.Trace("End => Get");
            }
        }