public async Task <ActionResult> AddABook([FromBody] PostBookCreate bookToAdd) { // 3. Add it to the database GetABookResponse response = await Mapper.AddBook(bookToAdd); return(CreatedAtRoute("books#getabook", new { bookId = response.Id }, response)); }
public async Task <ActionResult> AddABook([FromBody] PostBookCreate bookToAdd) { // X 1. Need a model for the post [FromBody] // 2. Validate the data coming in. // - declarative Validation // - Programmatic validation // - Return a 400 (Bad Request) //if(!ModelState.IsValid) //{ // return BadRequest(ModelState); //} // 3. Add it to the database GetABookResponse response = await Mapper.AddBook(bookToAdd); return(CreatedAtRoute("books#getabook", new { bookId = response.Id }, response)); }