public async void SaveButton() { var customerFormValidator = new CustomerFormValidator(); var validationResult = customerFormValidator.Validate(NewCustomer); // For testing CustomerValidationResult = validationResult.IsValid; if (validationResult.IsValid) { var customerEntity = NewCustomer.ConvertToCustomerEntity(); var resultTask = await _customers.AddCustomer(customerEntity); // For testing CustomerAddResult = resultTask; if (resultTask) { ClearFields(); await LoadCustomers(); } else { MessageBox.Show("Wystąpił błąd podczas zapisu danych. Spróbuj ponownie"); } } else { MessageBox.Show("Błąd walidacji danych."); } }
public async void SaveButton() { var customerModel = new CustomerModel() { Name = CustomerName, Address = CustomerAddress, City = CustomerCity }; var customerFormValidator = new CustomerFormValidator(); var validationResult = customerFormValidator.Validate(customerModel); // For testing CustomerValidationResult = validationResult.IsValid; if (validationResult.IsValid) { var customerEntity = customerModel.ConvertToCustomerEntity(); customerEntity.Id = customerId; var resultTask = await _customers.UpdateCustomer(customerEntity); // For testing CustomerUpdateResult = resultTask; if (resultTask) { _events.PublishOnUIThread(new CustomerCredentialsChangedEvent()); this.TryClose(); } else { MessageBox.Show("Błąd podczas zapisu danych. Spróbuj ponownie"); } } else { MessageBox.Show("Błąd walidacji danych"); } }