Ejemplo n.º 1
0
        private async Task OnCustomerDelete(int id)
        {
            var selectedCustomer = FindCustomerById(id);

            if (selectedCustomer == null)
            {
                throw new ArgumentException("No user");
            }

            var selCusAppointmnets = _allAppointments.Where(app => app._CustomerId == selectedCustomer._Id).ToList();

            Controls[ApplicationControls.CustomerDetail] = null;
            CurrentContent = Controls[ApplicationControls.CustomersList];

            _eventAggregator.GetEvent <CustomerIsLoadingEvent>().Publish(true);

            await _customerDataService.DeleteCustomerAsync(selectedCustomer);

            await _appointmentDataService.DeleteAppointmentListAsync(selCusAppointmnets);

            _customers.Remove(selectedCustomer);
            selCusAppointmnets.ForEach(app => _allAppointments.Remove(app));
            _customerAppointments.Clear();

            _eventAggregator.GetEvent <CustomerIsLoadingEvent>().Publish(false);
            _eventAggregator.GetEvent <AppointmentIsLoadingEvent>().Publish(false);
        }
Ejemplo n.º 2
0
        private async void DeleteCustomer()
        {
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                SelectedCustomer = await _CustomerDataService.DeleteCustomerAsync(SelectedCustomer);

                Customers.Remove(SelectedCustomer);
            }
        }