コード例 #1
0
        // POST: api/Book
        public HttpResponseMessage Post([FromBody] Book newBook)
        {
            //int newBookId = bookDBHelper.AddNewBook(newBook);
            bookDBHelper.AddNewBook(newBook);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created);

            //response.Headers.Location = new Uri(Request.RequestUri, String.Format("book/{0}", newBookId));
            response.Headers.Location = new Uri(Request.RequestUri, String.Format("book/{0}", 1));
            return(response);
        }
コード例 #2
0
 public bool AddNewBook(Book book)
 {
     book.Id = bookDBHelper.GetNextId();
     return(bookDBHelper.AddNewBook(book));
 }