private void btnDeleteBatch_Click( object sender, RoutedEventArgs e )
{
if ( MessageBox.Show( "Are you sure you want to delete this batch and all of its transactions?", "Confirm", MessageBoxButton.OKCancel ) == MessageBoxResult.OK )
{
try
{
if ( this.SelectedFinancialBatch != null )
{
RockConfig config = RockConfig.Load();
RockRestClient client = new RockRestClient( config.RockBaseUrl );
client.Login( config.Username, config.Password );
var transactions = grdBatchItems.DataContext as BindingList<FinancialTransaction>;
if ( transactions != null )
{
foreach ( var transaction in transactions )
{
client.Delete( string.Format( "api/FinancialTransactions/{0}", transaction.Id ) );
}
}
client.Delete( string.Format( "api/FinancialBatches/{0}", this.SelectedFinancialBatch.Id ) );
}
}
catch ( Exception ex )
{
ShowException( ex );
}
LoadFinancialBatchesGrid();
}
}