コード例 #1
0
 public async Task Remove()
 {
     try
     {
         if (_vehicle.SaleListing != null)
         {
             if (MessageBox.Show("A sale listing for this vehicle exists. By deleting the vehicle, its sale listing will be deleted as well.", "Sale listing exists", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
             {
                 await _saleListingCrudService.Delete(_vehicle.SaleListing.Id);
                 await DeleteVehicle();
             }
         }
         else
         {
             if (MessageBox.Show("Are you sure you want to delete this vehicle?", "Confirm delete", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
             {
                 await DeleteVehicle();
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("An error occured while deleting this vehicle", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #2
0
        private async Task DeleteVehicle()
        {
            await _vehicleSpecificationCrudService.Delete(_vehicle.VehicleSpecification.Id);

            await _vehicleCrudService.Delete(_vehicle.Vin);

            VehicleRemoved?.Invoke(this, EventArgs.Empty);
        }