예제 #1
0
        public bool UpdateGenre(GenreDetailAndEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Genres
                    .Single(e => e.GenreId == model.GenreId && e.OwnerId == _userId);
                entity.Type        = model.Type;
                entity.Description = model.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        public IHttpActionResult Put(GenreDetailAndEdit genre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateGenreService();

            if (!service.UpdateGenre(genre))
            {
                return(InternalServerError());
            }

            return(Ok());
        }