You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
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<Espece> ListeEspeces { get; set; }
|
|
|
|
[DataMember(Name = "animaux")]
|
|
public ObservableCollection<Animal> ListeAnimaux { get; set; }
|
|
|
|
public Theque()
|
|
{
|
|
ListeEspeces = Stub.LoadEspecetheque();
|
|
ListeAnimaux = new ObservableCollection<Animal>();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|