public async Task <IHttpActionResult> PutSongItem(int id, Song item) { SongBL bL = new SongBL(_context); if (!id.Equals(item.songID)) { return(BadRequest()); } else if (!bL.SongExists(id)) { var ItemId = await bL.CreateNewSong(item); if (ItemId == null) { return(InternalServerError()); } return(Created(Request.RequestUri, item)); } var isUpdated = await bL.UpdateSong(item); if (isUpdated == false) { return(InternalServerError()); } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostSong(Song item) { SongBL bL = new SongBL(_context); var ItemId = await bL.CreateNewSong(item); if (ItemId == null) { return(InternalServerError()); } return(Created(String.Format("{0}/{1}", Request.RequestUri, ItemId), item)); }