Пример #1
0
        private void AjouterPersonne(object sender, RoutedEventArgs e)
        {
            string      titre        = null;
            var         radios       = radioBtn.Children.OfType <RadioButton>();
            RadioButton checkedRadio = radios.FirstOrDefault(rb => rb.GroupName == "Titre" && rb.IsChecked == true);

            try
            {
                titre = checkedRadio.Content.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur à été levé" + ex.Message, "Exeption Levée", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            if (titre != null && Nom.Text != "" && Prenom.Text != "" && Email.Text != "" && Telephone.Text != "")
            {
                Personne personne = new Personne(titre, Nom.Text, Prenom.Text, Email.Text, Telephone.Text);
                personne.Add();
                AfficherLesPersonnes();
                Nom.Text               = "";
                Prenom.Text            = "";
                Email.Text             = "";
                Telephone.Text         = "";
                checkedRadio.IsChecked = false;
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs", "Erreur !", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Пример #2
0
 public IActionResult AddPersonne(string Autre, Personne p)
 {
     if (ModelState.IsValid)
     {
         //Personne p = new Personne()
         //{
         //    Nom = nom,
         //    Prenom = prenom
         //};
         p.Add();
         return(RedirectToAction("Accueil"));
     }
     else
     {
         return(RedirectToAction("FormPersonne"));
     }
 }
Пример #3
0
 public IActionResult AddPersonne(Personne p, IFormFile imagePersonne)
 {
     if (ModelState.IsValid)
     {
         //Test Taille Image
         if (imagePersonne.Length < (2 * 1000 * 1000 * 8))
         {
         }
         string     path   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/images", imagePersonne.FileName);
         FileStream stream = new FileStream(path, FileMode.Create);
         imagePersonne.CopyTo(stream);
         p.Image = imagePersonne.FileName;
         p.Add();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("AddFormPersonne"));
     }
 }
Пример #4
0
 public bool Post([FromBody] Personne p)
 {
     p.Add();
     return(p.Id > 0);
 }