protected override void InitializeCommands() { base.InitializeCommands(); Delete = new RelayCommand(o => { IsClosing = true; ApplicationViewModel.RestClient.ExecuteAsync <Artist>(ApplicationViewModel.RequestFactory.DeleteSongRequest(model.Id), (r, c) => { if (r.Succeeded()) { ApplicationViewModel.DisplayView.Execute(model.Album); ApplicationViewModel.ClearHistory(); } else { ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse()); } }); /*Response<bool> response = DataProvider.DeleteSong(model.Id); * if (!response.Status) ApplicationViewModel.HandleError(response.Error); * else * { * ApplicationViewModel.DisplayView.Execute(model.Album); * ApplicationViewModel.ClearHistory(); * }*/ }); Home = new RelayCommand(o => { IsClosing = true; ApplicationViewModel.Home.Execute(null); }); Back = new RelayCommand(o => { IsClosing = true; ApplicationViewModel.PreviousPage.Execute(null); }); Edit = new RelayCommand(o => { IsClosing = true; ApplicationViewModel.EditView.Execute(Model); }); NextCommentPage = new RelayCommand(o => RefreshComments(Model.Id, CommentPage.PageNumber + 1)); PreviousCommentPage = new RelayCommand(o => RefreshComments(Model.Id, CommentPage.PageNumber - 1)); PostComment = new RelayCommand(o => { Comment comment = new Comment() { EntityType = EntityType.SONG, User = LoginSession.Authentication.User, EntityId = Model.Id, Content = CommentContent }; RestClient.ExecuteAsync <Comment>(RequestFactory.AddCommentRequest(comment), (resp, handle) => { if (resp.Succeeded()) { RefreshComments(Model.Id, 1); } else { ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse()); } }); }); AdminDeleteComment = new RelayCommand(o => { if (!(o is Comment)) { return; } Comment comment = o as Comment; RestClient.ExecuteAsync(RequestFactory.DeleteCommentRequest(comment.Id), (resp, handle) => { if (resp.Succeeded()) { RefreshComments(Model.Id, CommentPage.PageNumber); } else { ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse()); } }); }); }
protected override void InitializeCommands() { base.InitializeCommands(); Delete = new RelayCommand(o => { ApplicationViewModel.RestClient.ExecuteAsync <Artist>(ApplicationViewModel.RequestFactory.DeleteArtistRequest(model.Id), (r, c) => { if (r.Succeeded()) { ApplicationViewModel.Search.Execute(model.Name); ApplicationViewModel.ClearHistory(); } else { ApplicationViewModel.HandlExceptionResponse(r.ExceptionResponse()); } }); /* * Response<bool> response = DataProvider.DeleteArtist(model.Id); * if (!response.Status) ApplicationViewModel.HandleError(response.Error); * else * { * ApplicationViewModel.Search.Execute(model.Name); * ApplicationViewModel.ClearHistory(); * }*/ }); CreateAlbum = new RelayCommand(o => { ApplicationViewModel.CreateView.Execute(new CreateAlbumViewModel(ApplicationViewModel, DataProvider, model)); }); NextCommentPage = new RelayCommand(o => RefreshComments(Model.Id, CommentPage.PageNumber + 1)); PreviousCommentPage = new RelayCommand(o => RefreshComments(Model.Id, CommentPage.PageNumber - 1)); PostComment = new RelayCommand(o => { Comment comment = new Comment() { EntityType = EntityType.ARTIST, User = LoginSession.Authentication.User, EntityId = Model.Id, Content = CommentContent }; RestClient.ExecuteAsync <Comment>(RequestFactory.AddCommentRequest(comment), (resp, handle) => { if (resp.Succeeded()) { RefreshComments(Model.Id, 1); } else { ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse()); } }); }); AdminDeleteComment = new RelayCommand(o => { if (!(o is Comment)) { return; } Comment comment = o as Comment; RestClient.ExecuteAsync(RequestFactory.DeleteCommentRequest(comment.Id), (resp, handle) => { if (resp.Succeeded()) { RefreshComments(Model.Id, CommentPage.PageNumber); } else { ApplicationViewModel.HandlExceptionResponse(resp.ExceptionResponse()); } }); }); }