public async Task <ActionResult> PauseCurrentTrack() { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser")); } } else { return(RedirectToAction("LoginUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var tryPauseTrack = await _playerRepo.PauseCurrentPlayBack(client); var modelValues = await GetPrivateUserDefaultModel(client); _model = modelValues; return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); throw; } }
public async Task <ActionResult> Index(string playListId) { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser", "SpotifyUser")); } } else { return(RedirectToAction("LoginUser", "SpotifyUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var playList = await _playListRepo.GetPlayList(playListId, client); var playListModel = _mapper.Map <FullPlayListModel>(playList); foreach (var pList in playList.Tracks.Items.ToList()) { if (pList?.Track?.Type == ItemType.Track) { var trackModel = new PlayListTrackModel <FullTrackModel> { AddedAt = pList.AddedAt, AddedBy = _mapper.Map <PublicUserModel>(pList.AddedBy), IsLocal = pList.IsLocal, Track = _mapper.Map <FullTrackModel>(pList.Track) }; playListModel.Tracks.Add(trackModel); } } _model.PlayList = playListModel; return(View(_model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } }
public async Task <ActionResult> Details(string artistId) { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser", "SpotifyUser")); } } else { return(RedirectToAction("LoginUser", "SpotifyUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var artistRes = _artistRepo.GetArtist(artistId, client); var artistAlbums = _artistRepo.GetArtistAlbums(artistId, client); var artistTopTracks = _artistRepo.GetArtistTopTracks(artistId, client); await Task.WhenAll(artistRes, artistAlbums, artistTopTracks); var artistmodel = _mapper.Map <FullArtistModel>(artistRes.Result); var artistAlbumsModel = _mapper.Map <List <SimpleAlbumModel> >(artistAlbums.Result); var artistTopTracksModel = _mapper.Map <List <FullTrackModel> >(artistTopTracks.Result); _model.ArtistModel = artistmodel ?? new FullArtistModel(); _model.ArtistAlbums = artistAlbumsModel ?? new List <SimpleAlbumModel>(); _model.ArtistTopTracks = artistTopTracksModel ?? new List <FullTrackModel>(); return(View(_model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } }
public async Task <ActionResult> CategoryPlayList (string categoryId) { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser", "SpotifyUser")); } } else { return(RedirectToAction("LoginUser", "SpotifyUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var categoryPlayLists = await _browseRepo .GetCategoryPlayLists(categoryId, client); var categoryPlayListsModel = _mapper .Map <List <SimplePlayListModel> >(categoryPlayLists); if (categoryPlayListsModel != null) { _model.CategoryPlayLists = categoryPlayListsModel; } return(View(_model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } }
public async Task <ActionResult> GetSearchedValues (BrowseViewModel inputModel) { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser", "SpotifyUser")); } } else { return(RedirectToAction("LoginUser", "SpotifyUser")); } if (ModelState.IsValid) { try { var searchRequestSpotify = _mapper.Map <SearchRequest>(inputModel.SearchModel); client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var searchRes = await _browseRepo.GetSearchResult(searchRequestSpotify, client); var searchResModel = _mapper.Map <SearchResponseModel>(searchRes); _model.SearchResponseModel = searchResModel; return(View(_model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } } return(View(_model)); }
public async Task <ActionResult> GetPublicUserProfile(string userid) { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser")); } } else { return(RedirectToAction("LoginUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var userProfile = _userRepo.GetPublicUser(userid, client); var userPlayList = _userRepo.GetPublicUserPlayLists(userid, client); await Task.WhenAll(userProfile, userPlayList); var userProfileModel = _mapper.Map <PublicUserModel>(userProfile.Result); var userPlayListsModel = _mapper.Map <List <SimplePlayListModel> >(userPlayList.Result); _userModel.UserModel = userProfileModel; _userModel.UserPublicPlayLists = userPlayListsModel; return(View(_userModel)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } }
public async Task <ActionResult> Details(string trackId) { try { var tokenGiven = _cookiesManager.GetCookie("TokenGiven", Request); var tokenTimes = _cookiesManager.GetCookie("TokenTime", Request); if (tokenGiven != null && tokenTimes != null) { if (ApiClientConfig.IsIfTokenExpired(Convert.ToDateTime(tokenTimes.Value), tokenGiven.Value)) { return(RedirectToAction("LoginUser", "SpotifyUser")); } } else { return(RedirectToAction("LoginUser", "SpotifyUser")); } client = ApiClientConfig.GetClientInstance(tokenGiven.Value); var trackRes = await _trackrepo.GetTrack(trackId, client); var albumRes = await _trackrepo.GetTrackAlbum(trackRes.Album.Id, client); var trackmodel = _mapper.Map <FullTrackModel>(trackRes); var albumModel = _mapper.Map <FullAlbumModel>(albumRes); _model.AlbumModel = albumModel; _model.TrackModel = trackmodel; return(View(_model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(ERROR_MESSAGE_PATH)); } }