public Guid Save(ApiContact model) { var contactEntity = UnitOfWork.GetRepository <Contact>().GetById(model.Id); SetContactPhone(model); if (contactEntity == null) { contactEntity = Mapper.Map <ApiContact, Contact>(model); contactEntity.CreatedDate = contactEntity.LastModifiedDate = DateTime.UtcNow; UnitOfWork.GetRepository <Contact>().Insert(contactEntity); } else { contactEntity = Mapper.Map(model, contactEntity); contactEntity.LastModifiedDate = DateTime.UtcNow; UnitOfWork.GetRepository <Contact>().Update(contactEntity); } UnitOfWork.SaveChanges(); return(contactEntity.Id); }
private void buttonModifier_Click(object sender, EventArgs e) { if (user == null || dataGridView1.CurrentRow == null) { return; } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null && ListeContacts != null) { DelegateChargerListeContact d = ChargerListeContacts; long idcontact = long.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); if (ListeContacts != null) { Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault(); if (c != null) { FicheContactForm w = new FicheContactForm(template, user.getIduser(), d, c); w.ShowDialog(); } } } }
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 void Delete(ApiContact model) { model.IsDeleted = true; model.LastModifiedDate = DateTime.UtcNow; Save(model); // UnitOfWork.GetRepository<Contact>().Delete(model.Id); // UnitOfWork.SaveChanges(); }
public async Task AddOrMergeContact(string email, string firstName, string lastName) { var contact = new ApiContact() { Email = email, FirstName = firstName, LastName = lastName }; await _ontraContacts.CreateOrMergeAsync(contact.GetChanges()); }
protected void GridViewListeContact_RowDeleting(object sender, GridViewDeleteEventArgs e) { int idcontact = 0; Int32.TryParse((string)e.Values["idcontact"], out idcontact); //supprime le contact par l'API ApiContact.DeleteContactById(idcontact); //suprimme le contact dans la base locale dao.DaoContact.deleteContactByID(idcontact); }
/// <summary> /// Update a contact /// </summary> /// <param name="value">Contact to update</param> /// <returns></returns> public JsonResult <ApiBaseResponse> Put([FromBody] ApiContact value) { var result = new ApiBaseResponse(); try { ServicesHost.GetService <IContactsProvider>().Save(value); } catch (Exception ex) { result.Status = Core.Enums.ApiStatusCode.SystemError; result.Error = ex.Message; } return(Json(result)); }
private void buttonAjouter_Click(object sender, EventArgs e) { if (user == null) { return; } Template template = GestionContacts.GetTemplate(ApiContact.GetStringJSonTemplate(user)); if (template != null) { DelegateChargerListeContact d = ChargerListeContacts; FicheContactForm w = new FicheContactForm(template, user.getIduser(), d); w.ShowDialog(); } }
/// <summary> /// add new contact (marked as a Party Guest) /// </summary> /// <param name="contact"></param> internal static void GuestRegistrationStarted(Contact contact) { if (DotMailerService.DotMailerEnabled) { try { // create contact ApiContact apiContact = DotMailerService.GetApiService().CreateContact(contact.ToApiContact()); // update local member with dotMailerId contact.Partier.DotMailerId = apiContact.Id; } catch (Exception exception) { LogHelper.Error(typeof(DotMailerService), "GuestRegistrationStarted", exception); } } }
private void buttonSupprimer_Click(object sender, EventArgs e) { if (dataGridView1.CurrentRow != null) { Console.WriteLine(dataGridView1.CurrentRow.Cells[0]); long idcontact = long.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString()); if (ListeContacts != null) { Contact c = ListeContacts.Where(x => x.getIdcontact() == idcontact).FirstOrDefault(); if (c != null) { ApiContact.DeleteContact(c); ChargerListeContacts(); } } } }
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(); } } }
private void ChargerListeContacts() { this.Cursor = Cursors.WaitCursor; toolStripLabelInfo.Text = ""; dataGridView1.DataSource = null; user = null; try { string strJson = ApiContact.GetStringJSonUser(textBoxLogin.Text, textBoxPassword.Text); user = GestionContacts.GetUser(strJson); if (user == null) { toolStripLabelInfo.Text = "Utilisateur non valide."; } else { textBoxLogin.Enabled = false; textBoxPassword.Enabled = false; buttonConnexion.Text = "Déconnexion"; } strJson = ApiContact.GetStringJSonContacts(user); ListeContacts = GestionContacts.GetContacts(strJson); SetDataGridView(GetDataTableFromListContacts(ListeContacts)); } catch (Exception ex) { toolStripLabelInfo.Text = "Erreur de connexion: " + ex.Message; } finally { this.Cursor = Cursors.Default; } ConnecteVisible = (user != null); }
private void SetContactPhone(ApiContact contact) { if (string.IsNullOrWhiteSpace(contact.PhoneNumber)) { return; } var phone = UnitOfWork.GetRepository <Phone>().GetAll().FirstOrDefault(p => p.Number == contact.PhoneNumber); if (phone == null) { phone = new Phone { Number = contact.PhoneNumber }; UnitOfWork.GetRepository <Phone>().Insert(phone); UnitOfWork.SaveChanges(); } contact.PhoneId = phone.Id; }