示例#1
0
        private async void OnNewCustomerCreate(CustomerWrapper newCustomer)
        {
            Controls[ApplicationControls.CustomerDetail] = null;
            CurrentContent = Controls[ApplicationControls.CustomersList];

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

            if (newCustomer != null)
            {
                //catches exeption if phone number is not a number
                try
                {
                    if (newCustomer._ExistingCustomer)
                    {
                        await _customerDataService.UpdateCustomerAsync(newCustomer, _user);
                    }
                    else
                    {
                        await _customerDataService.SaveNewCustomerAsync(newCustomer, _user);
                    }
                }
                catch (InvalidCustomerDataException ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                }

                await LoadCustomerData();
            }
            _eventAggregator.GetEvent <CustomerIsLoadingEvent>().Publish(false);
        }