private async void Edit_Button_ClickAsync(object sender, RoutedEventArgs e) { if (itemsList.SelectedItem == null) { return; } await TryCatchUpdateVMErrMessageTask(async() => { var car = itemsList.SelectedItem as Car; var carWindow = new CarWindow( new Car { Id = car.Id, Model = car.Model, Brand = car.Brand, Owner = car.Owner } ); if (carWindow.ShowDialog() == true) { await DataStore.UpdateItemAsync( new Car { Id = carWindow.Car.Id, Model = carWindow.Car.Model, Brand = carWindow.Car.Brand, Owner = carWindow.Car.Owner } ); } }); }
private async void Add_Button_ClickAsync(object sender, RoutedEventArgs e) { await TryCatchUpdateVMErrMessageTask(async() => { var carWindow = new CarWindow(new Car()); if (carWindow.ShowDialog() == true) { if (string.IsNullOrEmpty(carWindow.Car.Model) || string.IsNullOrEmpty(carWindow.Car.Brand)) { MessageBox.Show("Model and Brand are required!", "Cars Managment Alert", MessageBoxButton.OK, MessageBoxImage.Information); return; } await DataStore.AddItemAsync( new Car { Model = carWindow.Car.Model, Brand = carWindow.Car.Brand, Owner = carWindow.Car.Owner } ); } }); }