public static bool AjouterContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary newValues) { ContactEntity.Contact c = new ContactEntity.Contact(); Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); c.setIdcontact(0); c.setIduser(template.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); if (c != null) { List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues); c.setIduser(user.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); c.setDonnees(donnees); c.setIduser(user.getIduser()); ContactWrapper cw = new ContactWrapper(); cw.setContact(c); cw.setIdtemplate(template.getIdtemplate()); ApiContact.SetContact(cw); return(true); } return(false); }
public static void SaveContactAPI(ContactEntity.User user, System.Collections.Specialized.IOrderedDictionary oldValues, System.Collections.Specialized.IOrderedDictionary newValues) { if (user == null) { return; } //charge la liste des contacts par l'API string strJson = ContactClasse.ApiContact.GetStringJSonContacts(user); List <ContactEntity.Contact> ListeContacts = ContactClasse.GestionContacts.GetContacts(strJson); List <EvalEntity.Champ> listeChamp = dao.DaoChamp.GetChamps(); int idcontact = 0; if (oldValues != null) { idcontact = Int32.Parse(oldValues["idcontact"] as string); } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null && ListeContacts != null) { ContactEntity.Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault(); if (c != null) { List <ContactEntity.Donnee> donnees = SetListeDonnees(newValues); c.setIduser(user.getIduser()); c.setDtcreation(DateTime.Now); c.setFavoris(false); c.setActif(true); c.setDonnees(donnees); c.setIduser(user.getIduser()); ContactWrapper cw = new ContactWrapper(); cw.setContact(c); cw.setIdtemplate(template.getIdtemplate()); ApiContact.SetContact(cw); } } }
private void BtnAjouter_Click(object sender, EventArgs e) { if (FormIsValid()) { contact = NouveauContact(); contact.setIduser(iduser); ContactWrapper cw = new ContactWrapper(); cw.setContact(contact); cw.setIdtemplate(template.getIdtemplate()); ApiContact.SetContact(cw); ChargerListeContact.DynamicInvoke(); if (this.panel1.Controls["BtnAjouter"] != null && this.panel1.Controls["BtnAjouter"].Text == "Ajouter") { contact = null; this.panel1.Controls.Clear(); this.InitialiseChamp(); } } }