public ActionResult <List <PlaylistGetModel> > GetAllPlaylist([FromHeader][Required] string jwtToken) { string creatorId = new PlaylistDataAccess().JwtTokenValidation(jwtToken); if (creatorId == "") { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "Invalid Jwt Token" })); } List <PlaylistGetModel> playlistGetModels = null; if (new PlaylistDataAccess().IsListenerOrArtist(creatorId)) { playlistGetModels = new PlaylistDataAccess().GetAllPlaylist(creatorId); } else { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "User Must be a Listener or Artist" })); } if (playlistGetModels != null) { return(playlistGetModels); } return(BadRequest(new CustomResponseModel() { Code = "400", Phrase = "BadRequest", Message = "Could Not Get All Playlist" })); }
public ActionResult <CustomResponseModel> RemoveSongPlaylist([FromHeader][Required] string jwtToken, [Required] string playlistId, [Required] string songId) { string userId = new PlaylistDataAccess().JwtTokenValidation(jwtToken); if (userId == "") { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "Invalid Jwt Token" })); } if (new PlaylistDataAccess().IsListenerOrArtist(userId)) { if (new PlaylistDataAccess().RemoveSongPlaylist(userId, playlistId, songId)) { return(Ok(new CustomResponseModel() { Code = "200", Phrase = "OK", Message = "Song Removed from Playlist" })); } } else { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "User Must be a Listener or Artist" })); } return(BadRequest(new CustomResponseModel() { Code = "400", Phrase = "BadRequest", Message = "Could Not Remove Song from Playlist" })); }