예제 #1
0
        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);
        }
예제 #2
0
        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);
        }