public void SaveNew(Bird bird) { if (bird.Name != null) { if (BirdDB.Add(bird)) { if (bird.BirdType == null) { bird.BirdType = "Unknown"; } if (bird.Length == null) { bird.Length = "Unknown"; } if (bird.Description == null) { bird.Description = "Add some description."; } if (bird.BaseColor == null) { bird.BaseColor = "Unknown"; } if (bird.ImageUrl == null) { bird.ImageUrl = "http://images.clipartpanda.com/bird-clipart-Twitter-Bird-Clip-Art.png"; } BirdDB.Update(bird); Birds.Add(bird); _listener.NotifyDataChanged(); CurrentBird = bird; CurrentWorkspace = new DetailsViewModel(this, (Bird)CurrentBird.Clone()); } else { MessageBox.Show("You already have this bird in your list!"); } } else { MessageBox.Show("You cannot create a nameless bird!"); } }
public void Save(Bird bird) { if (Birds.Contains(bird)) { if (bird.BirdType == "") { bird.BirdType = "Unknown"; } if (bird.Length == "") { bird.Length = "Unknown"; } if (bird.Description == "") { bird.Description = "Add some description."; } if (bird.BaseColor == "") { bird.BaseColor = "Unknown"; } BirdDB.Update(bird); Birds[Birds.IndexOf(bird)] = bird; _listener.NotifyDataChanged(); CurrentBird = bird; CurrentWorkspace = new DetailsViewModel(this, (Bird)CurrentBird.Clone()); } }