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.
126 lines
3.6 KiB
126 lines
3.6 KiB
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
|
|
{
|
|
/// <summary>
|
|
/// Logique d'interaction pour AddAShark.xaml
|
|
/// </summary>
|
|
public partial class AddAShark : Window
|
|
{
|
|
public AddAShark()
|
|
{
|
|
InitializeComponent();
|
|
Mgr.LoadRequins();
|
|
|
|
DataContext = Mgr;
|
|
|
|
}
|
|
|
|
public Manager Mgr => (Application.Current as App).LeManager;
|
|
|
|
|
|
private List<Conservation> consList = new List<Conservation>
|
|
{
|
|
Conservation.EX,
|
|
Conservation.EW,
|
|
Conservation.CR,
|
|
Conservation.EN,
|
|
Conservation.VU,
|
|
Conservation.NT,
|
|
Conservation.LC,
|
|
Conservation.DD,
|
|
Conservation.NE
|
|
};
|
|
|
|
|
|
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<Zone> lesZones = new List<Zone>();
|
|
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;
|
|
|
|
|
|
foreach (Control control in this.radioButtons.Children)
|
|
{
|
|
if (control is RadioButton)
|
|
{
|
|
RadioButton radio = control as RadioButton;
|
|
if (radio.IsChecked == true)
|
|
{
|
|
if (radio.Content is string radString)
|
|
{
|
|
foreach (Conservation conserv in consList)
|
|
{
|
|
if (radString == conserv.ToString())
|
|
{
|
|
cons = conserv;
|
|
goto loopEnd;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
loopEnd:
|
|
|
|
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|