Exemple #1
0
        public ActionResult EditContact([Bind(Include = "id_Contact,Nom,Prenom,Courriel,Telephone,Poste,Facebook,SiteWeb,Local")] p_Contact contact)
        {
            ValiderContact(contact);
            string site     = contact.SiteWeb;
            string facebook = contact.Facebook;

            if (!site.StartsWith("https://") || site.StartsWith("http://"))
            {
                site = "https://" + site;
            }
            if (!facebook.StartsWith("https://") || facebook.StartsWith("http://"))
            {
                facebook = "https://" + facebook;
            }
            contact.Facebook = facebook;
            contact.SiteWeb  = site;

            if (ModelState.IsValid)
            {
                contact.Telephone        = SachemIdentite.FormatTelephone(contact.Telephone);
                _db.Entry(contact).State = EntityState.Modified;
                _db.SaveChanges();

                TempData["Success"] = string.Format(Messages.NousContaterMisAJour());
                return(View(contact));
            }
            return(View(contact));
        }
Exemple #2
0
 private void ValiderContact([Bind(Include = "id_Contact,Nom,Prenom,Courriel,Telephone,Poste,Facebook,SiteWeb,Local")] p_Contact contact)
 {
     if (!_db.p_Contact.Any(r => r.id_Contact == contact.id_Contact))
     {
         ModelState.AddModelError(string.Empty, " ");
     }
 }