public Contact CreateContact(ContactForm form) { try { Contact nouveau = new Contact(); nouveau.FromObject(form); if (form.Address != null && !string.IsNullOrWhiteSpace(form.Address.CodePostal)) { CONTACT.AddressProvider addrProvide = new AddressProvider(this.Connector); addrProvide.DefineAddress(nouveau, form.Address); } // Insert nouveau["IDContact"] = DBNull.Value; base.InsertBubble(nouveau, false, true); return(nouveau); } catch (Exception ex) { throw new Exception("CreateContact" + ex.Message, ex); } }
public Contact UpdateContact(ContactForm form) { try { Contact retour = this.GetContact(form.IDContact); if (retour == null) { throw new Exception("Contact not found"); } retour.FromObject(form); if (form.Address != null) { CONTACT.AddressProvider addrProvide = new AddressProvider(this.Connector); addrProvide.DefineAddress(retour, form.Address); } base.SaveBubble(retour); retour = this.GetContact(form.IDContact); return(retour); } catch (Exception ex) { throw new Exception("UpdateContact " + ex.Message, ex); } }
/// <summary> /// Trouver contact /// </summary> /// <param name="IDContact">id</param> /// <returns></returns> public Contact GetContact(int IDContact, bool Complete = true) { Dictionary <string, object> insaddr = new Dictionary <string, object>(); insaddr.Add("IDContact", IDContact); Contact retour = base.GetOneDefault <Contact>(insaddr); if (Complete) { CONTACT.AddressProvider addrProvide = new AddressProvider(this.Connector); if (retour.IDAddressPrimary != null) { retour.AddressPrimary = addrProvide.GetAddress(retour.IDAddressPrimary.Value); } } return(retour); }