using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using Business; using Modèle; namespace WpfApp1 { /// /// Logique d'interaction pour AddAShark.xaml /// public partial class AddAShark : Window { public AddAShark() { InitializeComponent(); Mgr.LoadRequins(); DataContext = Mgr; } public Manager Mgr => (Application.Current as App).LeManager; private void exit_Click(object sender, RoutedEventArgs e) { Close(); } private void submit_Click(object sender, RoutedEventArgs e) { int testCons = 0; Conservation cons = new Conservation(); List lesZones = new List(); string nom = name.LeContenu.Text; string sciNam = sciName.LeContenu.Text; string descri = desc.LeContenu.Text; string photo = lienPhoto.LeContenu.Text; string video = lienVid.LeContenu.Text; string map = lienMap.LeContenu.Text; string fun = funny.LeContenu.Text; if (ex.IsChecked==true) { cons = Conservation.EX; testCons++; } else if (ew.IsChecked == true) { cons = Conservation.EW; testCons++; } else if (cr.IsChecked == true) { cons = Conservation.CR; testCons++; } else if (en.IsChecked == true) { cons = Conservation.EN; testCons++; } else if (vu.IsChecked == true) { cons = Conservation.VU; testCons++; } else if (nt.IsChecked == true) { cons = Conservation.NT; testCons++; } else if (lc.IsChecked == true) { cons = Conservation.LC; } else if (dd.IsChecked == true) { cons = Conservation.DD; testCons++; } else if (ne.IsChecked == true) { cons = Conservation.NE; testCons++; } if (Arct.IsChecked == true) { lesZones.Add(Zone.ARCTIQUE); } if (Atla.IsChecked == true) { lesZones.Add(Zone.ATLANTIQUE); } if (Indi.IsChecked == true) { lesZones.Add(Zone.INDIEN); } if (Paci.IsChecked == true) { lesZones.Add(Zone.PACIFIQUE); } if (testCons == 0 || lesZones.Count() == 0 || string.IsNullOrWhiteSpace(nom) || string.IsNullOrWhiteSpace(sciNam) || string.IsNullOrWhiteSpace(descri) || string.IsNullOrWhiteSpace(photo) || string.IsNullOrWhiteSpace(video) || string.IsNullOrWhiteSpace(map) || string.IsNullOrWhiteSpace(fun)) { return; } else { Requin requin = new Requin(nom, sciNam, descri, photo, video, map, cons, lesZones, fun); Mgr.AjouterRequinAdd(requin); Close(); } } } }