public IHttpActionResult PostGenre(GenreDTO genre) { if (!ModelState.IsValid) { return BadRequest(ModelState); } df.GenreRepository.Add(new GenreConverter().Reverse(genre)); return CreatedAtRoute("DefaultApi", new { id = genre.GenreId }, genre); }
public IHttpActionResult PutGenre(int id, GenreDTO genre) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != genre.GenreId) { return BadRequest(); } try { df.GenreRepository.Edit(new GenreConverter().Reverse(genre)); } catch (DbUpdateConcurrencyException) { return NotFound(); } return StatusCode(HttpStatusCode.NoContent); }