Ejemplo n.º 1
0
        private void LoadBreeders()
        {
            var breeders = App.DogRepository.GetAll();

            uxBreederList.ItemsSource = breeders
                                        .Select(repostoryBreeder => BreederModel.ToModel(repostoryBreeder))
                                        .ToList();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 private void uxFileDelete_Click(object sender, RoutedEventArgs e)
 {
     App.DogRepository.Remove(selectedBreeder.Id);
     selectedBreeder = null;
     LoadBreeders();
 }
Ejemplo n.º 7
0
 private void uxBreederList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     selectedBreeder = (BreederModel)uxBreederList.SelectedValue;
 }