public IHttpActionResult Update(SongOutputModel updateSong) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var song = this.GetSongById(updateSong.Id); if (song == null) { return this.BadRequest(NoSuchSong); } song.Title = updateSong.Title; this.musicArtistsData.SaveChanges(); return this.Ok(updateSong); }
public IHttpActionResult Create(SongOutputModel song) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } this.musicArtistsData.Songs.Add(new Song { Id = song.Id, Title = song.Title }); this.musicArtistsData.SaveChanges(); return this.Ok(song); }