using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace Model { [DataContract(Name = "theque")] public class Theque { [DataMember(Name = "especes")] public List ListeEspeces { get; set; } [DataMember(Name = "animaux")] public ObservableCollection ListeAnimaux { get; set; } public Theque() { ListeEspeces = new List(); ListeAnimaux = new ObservableCollection(); } public Animal AjouterAnimal() { Animal animal = new Animal(); ListeAnimaux.Add(animal); return animal; } public void SupprimerAnimal(Animal animal) { ListeAnimaux.Remove(animal); } public Animal? RechercherAnimal(string choix) { foreach (Animal animal in ListeAnimaux) { if (animal.Nom == choix) { return animal; } } return null; } public Espece? RechercherEspece(string choix) { foreach (Espece espece in ListeEspeces) { if (espece.Nom == choix) { return espece; } } return null; } } }