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); } }
public IHttpActionResult Put(GenreDetailAndEdit genre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateGenreService(); if (!service.UpdateGenre(genre)) { return(InternalServerError()); } return(Ok()); }