public DisplayArtistViewModel(ApplicationViewModel applicationViewModel, IResponseDataProvider dataProvider, long artistId) : base(applicationViewModel, dataProvider)
        {
            RestClient.ExecuteAsync <ArtistWithAlbums>(RequestFactory.GetArtistWithAlbumsRequest(artistId),
                                                       (r, c) =>
            {
                if (r.Succeeded())
                {
                    Albums = new ObservableCollection <Album>(r.Data.Albums);
                    Model  = r.Data.Artist;

                    Console.WriteLine(Model.Name);
                }
                else
                {
                    ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                }
            });


            RefreshComments(artistId, 1);

            ApplicationViewModel.RestClient.ExecuteAsync <Rating>(
                RequestFactory.GetRatingRequest(EntityType.ARTIST, artistId, LoginSession.Authentication.User.Id),
                (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    rating     = resp.Data;
                    UserRating = resp.Data == null ? 0 : resp.Data.Value;
                }
                else
                {
                    resp.ExceptionResponse();
                    ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse());
                }
            });

            RestClient.ExecuteAsync <double>(RequestFactory.AverageRatingRequest(EntityType.ARTIST, artistId),
                                             (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    averageRating = resp.Data;
                }
                else
                {
                    ;
                }
            });

            /*Response<Artist> respArtist = DataProvider.GetArtistById(artistId);
             * Response<IList<Album>> respAlbums = DataProvider.GetAlbumsByArtist(artistId);
             * if (!respArtist.Status || !respAlbums.Status)
             * {
             *  ApplicationViewModel.HandleError(!respArtist.Status ? respArtist.Error : respAlbums.Error);
             *  return;
             * }
             * Albums = new ObservableCollection<Album>(respAlbums.Content);
             * Model = respArtist.Content;*/
        }
        public DisplayAlbumViewModel(ApplicationViewModel applicationViewModel, IResponseDataProvider dataProvider, long albumId) : base(applicationViewModel, dataProvider)
        {
            RestClient.ExecuteAsync <AlbumWithSongs>(RequestFactory.GetAlbumWithSongsRequest(albumId),
                                                     (r, c) =>
            {
                if (r.Succeeded())
                {
                    Songs = new ObservableCollection <Song>(r.Data.Songs);
                    Model = r.Data.Album;
                }
                else
                {
                    ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse());
                }
            });

            RefreshComments(albumId, 1);

            ApplicationViewModel.RestClient.ExecuteAsync <Rating>(
                RequestFactory.GetRatingRequest(EntityType.ALBUM, albumId, LoginSession.Authentication.User.Id),
                (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    rating     = resp.Data;
                    UserRating = resp.Data == null ? 0 : resp.Data.Value;
                }
                else
                {
                    resp.ExceptionResponse();
                    ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse());
                }
            });

            RestClient.ExecuteAsync <double>(RequestFactory.AverageRatingRequest(EntityType.ALBUM, albumId),
                                             (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    averageRating = resp.Data;
                }
                else
                {
                    ;
                }
            });

            /*Response<Album> respAlbum = DataProvider.GetAlbumById(albumId);
             * Response<IList<Song>> respSongs = DataProvider.GetSongsFromAlbum(albumId);
             * if (!respAlbum.Status || !respSongs.Status)
             * {
             *  ApplicationViewModel.HandleError(!respAlbum.Status ? respAlbum.Error : respSongs.Error);
             *  return;
             * }
             * Songs = new ObservableCollection<Song>(respSongs.Content);
             * Model = respAlbum.Content;*/
        }
        public DisplaySongViewModel(ApplicationViewModel applicationViewModel, IResponseDataProvider dataProvider, long songId) : base(applicationViewModel, dataProvider)
        {
            /*Response<Song> response = DataProvider.GetSongById(songId);
             * if (!response.Status)
             * {
             *  ApplicationViewModel.HandleError(response.Error);
             *  return;
             * }
             * Model = response.Content;*/
            ApplicationViewModel.RestClient.ExecuteAsync <Song>(
                ApplicationViewModel.RequestFactory.GetSongRequest(songId),
                (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    Model = resp.Data;
                }
                else
                {
                    ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse());
                }
            });
            RefreshComments(songId, 1);

            ApplicationViewModel.RestClient.ExecuteAsync <Rating>(
                RequestFactory.GetRatingRequest(EntityType.SONG, songId, LoginSession.Authentication.User.Id),
                (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    rating     = resp.Data;
                    UserRating = resp.Data == null? 0 : resp.Data.Value;
                }
                else
                {
                    resp.ExceptionResponse();
                    ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse());
                }
            });

            RestClient.ExecuteAsync <double>(RequestFactory.AverageRatingRequest(EntityType.SONG, songId),
                                             (resp, handle) =>
            {
                if (resp.Succeeded())
                {
                    averageRating = resp.Data;
                }
                else
                {
                    ;
                }
            });
        }
 private void UpdateUserRating()
 {
     if (rating != null)
     {
         rating.Value = userRating;
     }
     if (userRating < 1 || userRating > 5)
     {
         return;
     }
     RestClient.ExecuteAsync <Rating>(
         rating == null?
         RequestFactory.AddRatingRequest(new Rating()
     {
         EntityType = EntityType.SONG,
         EntityId   = Model.Id,
         Value      = UserRating,
         User       = LoginSession.Authentication.User
     }) : RequestFactory.UpdateRatingRequest(rating),
         (resp, handle) =>
     {
         if (resp.Succeeded())
         {
             rating    = resp.Data;
             var resp2 = RestClient.Execute <double>(RequestFactory.AverageRatingRequest(EntityType.SONG, Model.Id));
             if (resp2.Succeeded())
             {
                 AverageRating = resp2.Data;
             }
             else
             {
                 ApplicationViewModel.HandlExceptionResponse(resp2.ExceptionResponse());
             }
         }
         else
         {
             ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse());
         }
     });
 }