예제 #1
0
 public Book Get(int id)
 {
     try
     {
         return(_booksProvider.GetBook(id));
     }
     catch
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
     }
 }
예제 #2
0
        public IHttpActionResult Get(string code)
        {
            try
            {
                var book = _booksProvider.GetBook(code);
                if (book == null)
                {
                    return(NotFound());
                }

                return(Ok(book));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
예제 #3
0
        public void GetBook()
        {
            var book = _booksProvider.GetBook("NET-0001");

            Assert.IsTrue(book != null);
        }
 // GET: api/Books/5
 public Book Get(int id)
 {
     return(_booksProvider.GetBook(id));
 }