public ActionResult AddTrack(long playlistId, string id) { if (!ModelState.IsValid) { return(View("View")); } var track = trackProvider.LookupTrack(id); if (track == null) { return(new HttpStatusCodeResult(400)); } var albumArtUrl = albumArtProvider.Find(track.Artist + " " + track.Title); track.CoverArtUrl = albumArtUrl; track = playlistManager.AddTrackToPlaylist( playlistId, track ); if (track == null) { return(new HttpStatusCodeResult(400, "You can not add a song that is already in the list")); } var trackCount = playlistManager.ReadPlaylist(playlistId).PlaylistTracks.Where(p => p.PlayedAt == null).ToList().Count; return(Json(trackCount, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult AddTrack(long playlistId, string trackId) { var track = trackProvider.LookupTrack(trackId); if (track == null) { return(NotFound()); } var albumArtUrl = albumArtProvider.Find(track.Artist + " " + track.Title); track.CoverArtUrl = albumArtUrl; track = playlistManager.AddTrackToPlaylist( playlistId, track ); if (track == null) { return(NotFound()); } return(Ok(track)); }