diff --git a/Modèle/Expert.cs b/Modèle/Expert.cs index 1637eae..c5fa01a 100644 --- a/Modèle/Expert.cs +++ b/Modèle/Expert.cs @@ -64,5 +64,42 @@ namespace Modèle return i; } + + public int ValiderUnChangement(List lBdFinie, List lBdPasfinie) + { + int i = 0; + string rep; + List nv = new List(); + foreach (Requin r in lBdPasfinie) + { + nv.Add(r); + } + foreach (Requin r in nv) + { + Console.WriteLine(r); + Console.WriteLine("Voulez vous ajoutez ce requin à la base de données des requins ? (y/n)"); + rep = Console.ReadLine(); + while (rep != "n" && rep != "y") + { + Console.WriteLine("Erreur de saisie (y/n)"); + rep = Console.ReadLine(); + } + if (rep == "y") + { + lBdFinie.Remove(r); + lBdFinie.Add(r); + i++; + } + lBdPasfinie.Remove(r); + + } + return i; + } + + + public bool Equals(Expert e) + { + return Email == e.Email; + } } } diff --git a/Modèle/Requin.cs b/Modèle/Requin.cs index a9a264a..a6bcb13 100644 --- a/Modèle/Requin.cs +++ b/Modèle/Requin.cs @@ -54,19 +54,19 @@ namespace Modèle public void ModiferRequin(string description, string photo, string video, string photoCarte, Conservation statutCons, List repartition, string funFact) { - if (description != "") + if (! string.IsNullOrWhiteSpace(description)) { Description = description; } - if(photo != "") + if(! string.IsNullOrWhiteSpace(photo)) { Photo = photo; } - if(video != "") + if(!string.IsNullOrWhiteSpace(video)) { Video = video; } - if (photoCarte != "") + if (!string.IsNullOrWhiteSpace(photoCarte)) { Photo = photoCarte; } @@ -74,7 +74,7 @@ namespace Modèle { StatutCons = statutCons; } - if (funFact != "") + if (!string.IsNullOrWhiteSpace(funFact)) { FunFact = funFact; } @@ -87,6 +87,15 @@ namespace Modèle } } + public bool Equals(Requin r) + { + if (Nom==r.Nom && NomSci == r.NomSci) + { + return true; + } + return false; + } + } } diff --git a/Modèle/UserControlRequin.cs b/Modèle/UserControlRequin.cs new file mode 100644 index 0000000..39e85ab --- /dev/null +++ b/Modèle/UserControlRequin.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Modèle +{ + class UserControlRequin + { + } +} diff --git a/Modèle/Utilisateur.cs b/Modèle/Utilisateur.cs index fc571fc..44fd6ad 100644 --- a/Modèle/Utilisateur.cs +++ b/Modèle/Utilisateur.cs @@ -41,5 +41,11 @@ namespace Modèle lBdPasFinie.Add(req); NbSubmit++; } + + + public bool Equals(Utilisateur u) + { + return Email == u.Email; + } } } diff --git a/WpfApp1/UserControlEdit.xaml.cs b/WpfApp1/UserControlEdit.xaml.cs index 48b312d..a19b846 100644 --- a/WpfApp1/UserControlEdit.xaml.cs +++ b/WpfApp1/UserControlEdit.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Modèle; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,50 +24,10 @@ namespace WpfApp1 public UserControlEdit() { InitializeComponent(); + } - public string name - { - set - { - leNom.Contenu = value; - } - } - public string sciName - { - set - { - nomSci.Contenu = value; - } - } - public string pic - { - set - { - LienPhoto.Contenu = value; - } - } - public string vid - { - set - { - LienVid.Contenu = value; - } - } - public string map - { - set - { - LienMap.Contenu = value; - } - } - public string fun - { - set - { - funFact.Contenu = value; - } - } + public Requin requin { get; set; } private void LienPhoto_IsKeyboardFocusedChanged(object sender, DependencyPropertyChangedEventArgs e) { diff --git a/WpfApp1/UserControlRequin.xaml b/WpfApp1/UserControlRequin.xaml index 9bebfc1..057f838 100644 --- a/WpfApp1/UserControlRequin.xaml +++ b/WpfApp1/UserControlRequin.xaml @@ -20,9 +20,9 @@ - - - + + + diff --git a/WpfApp1/UserControlRequin.xaml.cs b/WpfApp1/UserControlRequin.xaml.cs index c8e644a..59e8a39 100644 --- a/WpfApp1/UserControlRequin.xaml.cs +++ b/WpfApp1/UserControlRequin.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Modèle; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,6 +13,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; + + namespace WpfApp1 { /// @@ -22,6 +25,10 @@ namespace WpfApp1 public UserControlRequin() { InitializeComponent(); + name.Text = requin.Nom; + sciName.Text = requin.NomSci; + image.Source = new BitmapImage(new Uri(requin.Photo, UriKind.Relative)); + } @@ -29,5 +36,9 @@ namespace WpfApp1 { ((MainWindow)System.Windows.Application.Current.MainWindow).ContentControlSwapDes(); } + + public Requin requin { get; private set; } + + } } diff --git a/WpfApp1/WpfApp1.csproj b/WpfApp1/WpfApp1.csproj index 8a6acfd..8d22384 100644 --- a/WpfApp1/WpfApp1.csproj +++ b/WpfApp1/WpfApp1.csproj @@ -56,6 +56,7 @@ + diff --git a/test_requin/Program.cs b/test_requin/Program.cs index 33d58e6..3c74ea1 100644 --- a/test_requin/Program.cs +++ b/test_requin/Program.cs @@ -45,13 +45,17 @@ namespace test_requin { Console.WriteLine(r); } + + finie.Clear(); + finie.Add(requin); Console.WriteLine(e1); Console.WriteLine(e2); List z = new List(); Console.WriteLine("----------------------------------------------------------------------------------\n"); u1.FaireUnChangement(requin, "lalalilalou", "", "", "", Conservation.NE, z, "hahahahaha", bdd); - foreach(Requin r in bdd) + e1.ValiderUnChangement(finie, bdd); + foreach(Requin r in finie) { Console.WriteLine(r); }