public void PetTrackerRemove() { var findTrackerWindow = new FindTracker(); if (findTrackerWindow.ShowDialog() == true) { if (findTrackerWindow.uxNumber.Text != "") { FindNumber = Convert.ToInt32(findTrackerWindow.uxNumber.Text); var selectedRepositoryModel = App.PetTrackerRepository.GetAll().Find(t => t.Number == FindNumber); if (selectedRepositoryModel == null) { MessageBox.Show("Can't find this record."); } else if (selectedRepositoryModel != null) { var selectedModel = PetTrackerModel.ToModel(selectedRepositoryModel); var petTrackerWindow = new UpdatePetTracker(); petTrackerWindow.uxSubmit.Content = "Delete"; petTrackerWindow.PetTrackerModel = selectedModel; if (petTrackerWindow.ShowDialog() == true) { App.PetTrackerRepository.Remove(FindNumber); } } LoadPetTracker(); } } }
public void LoadPetTracker() { var petTracker = App.PetTrackerRepository.GetAll(); uxPetTrackerList.ItemsSource = petTracker .Select(t => PetTrackerModel.ToModel(t)) .ToList(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (PetTrackerModel == null) { PetTrackerModel = new PetTrackerModel(); PetTrackerModel.CreatedDate = DateTime.Now; } uxGrid.DataContext = PetTrackerModel; }
private void uxSubmit_Click(object sender, RoutedEventArgs e) { PetTrackerModel = new PetTrackerModel { Number = Convert.ToInt32(uxNumber), Breed = uxBreed.Text, Description = uxDescription.Text, Price = Convert.ToDecimal(uxPrice), Quantity = Convert.ToInt32(uxQuantity), Cost = Convert.ToDecimal(uxCost), }; DialogResult = true; Close(); }