public IHttpActionResult Put(SongFetch song) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateSongService(); if (!service.UpdateSong(song)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateSong(SongFetch model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Songs .Single(e => e.SongId == model.SongId); entity.SongName = model.SongName; entity.GenreId = model.GenreId; entity.Album = model.Album; entity.Artist = model.Artist; entity.ChildFriendly = model.ChildFriendly; return(ctx.SaveChanges() == 1); } }