private void LoadBreeders() { var breeders = App.DogRepository.GetAll(); uxBreederList.ItemsSource = breeders .Select(repostoryBreeder => BreederModel.ToModel(repostoryBreeder)) .ToList(); }
public bool Update(BreederModel breederModel) { var original = DatabaseManager.Instance.Breeder.Find(breederModel.Id); if (original != null) { DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(ToDbModel(breederModel)); DatabaseManager.Instance.SaveChanges(); return(true); } return(false); }
private Breeder ToDbModel(BreederModel breederModel) { var dogBusinessDb = new Breeder { DogAge = breederModel.Age, DogCreatedDate = breederModel.CreatedDate, DogGender = breederModel.Gender, DogId = breederModel.Id, DogName = breederModel.Name, DogNotes = breederModel.Notes, DogBreed = breederModel.Breed, LitterCount = breederModel.LitterCount, CurrentPuppyCount = breederModel.CurrentPuppyCount, }; return(dogBusinessDb); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (Breeder != null) { if (Breeder.Gender == "Male") { uxMale.IsChecked = true; } else { uxFemale.IsChecked = true; } } else { Breeder = new BreederModel(); Breeder.CreatedDate = DateTime.Now; } uxGrid.DataContext = Breeder; }
public BreederModel Add(BreederModel breederModel) { var dogBusinessDb = ToDbModel(breederModel); DatabaseManager.Instance.Breeder.Add(dogBusinessDb); DatabaseManager.Instance.SaveChanges(); breederModel = new BreederModel { Age = dogBusinessDb.DogAge, CreatedDate = dogBusinessDb.DogCreatedDate, Gender = dogBusinessDb.DogGender, Id = dogBusinessDb.DogId, Name = dogBusinessDb.DogName, Notes = dogBusinessDb.DogNotes, Breed = dogBusinessDb.DogBreed, LitterCount = dogBusinessDb.LitterCount, CurrentPuppyCount = dogBusinessDb.CurrentPuppyCount }; return(breederModel); }
private void uxFileDelete_Click(object sender, RoutedEventArgs e) { App.DogRepository.Remove(selectedBreeder.Id); selectedBreeder = null; LoadBreeders(); }
private void uxBreederList_SelectionChanged(object sender, SelectionChangedEventArgs e) { selectedBreeder = (BreederModel)uxBreederList.SelectedValue; }