protected override async void DeleteSelected() { if ( MessageBox.Show("Are you sure you want to delete this centre", "Agrimanagr: Activate Centre", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) return; using (var c = NestedContainer) { if (SelectedCentreItem.Centre._Status == EntityStatus.Active) { if (Using<IMasterDataUsage>(c).CheckAgriCentreIsUsed(SelectedCentreItem.Centre, EntityStatus.Deleted)) { MessageBox.Show( "Centre " + SelectedCentreItem.Centre.Name + " has been allocated to commodity producers. Unallocate first to delete this centre.", "Agrimanagr: Delete Centre", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } ResponseBool response = new ResponseBool() {Success = false}; if (SelectedCentreItem == null) return; _proxy = Using<IDistributorServiceProxy>(c); response = await _proxy.CentreDeleteAsync(SelectedCentreItem.Centre.Id); if(response.Success) { Using<ICentreRepository>(c).SetAsDeleted(SelectedCentreItem.Centre); } MessageBox.Show(response.ErrorInfo, "Agrimangr: Manage Centre", MessageBoxButton.OK, MessageBoxImage.Information); } }