public void actEdit(object obj) { bool error = false; this.validName = new Validation(); // Validation nom de l'organisation if (!this.name.Equals("")) { this.validName.message = "Valide"; this.validName.valid = true; NotifyPropertyChanged("validFirstname"); } else { this.validName.message = "Champ requis"; this.validName.valid = false; NotifyPropertyChanged("validFirstname"); error = true; } if (!error) { currentOrganisation.name = this.name; currentOrganisation.street = this.street; currentOrganisation.city = this.city; currentOrganisation.zip = this.zip; currentOrganisation.country = this.country; // Numéro de téléphone if (!this.phone.Equals("")) { if (currentOrganisation.phone != null) currentOrganisation.phone.number = this.phone; else { phone phone = new phone(); phone.number = this.phone; phone.description = "main"; phone.main = true; currentOrganisation.phone = phone; } } // Adresse email if (!this.email.Equals("")) { if (currentOrganisation.email != null) currentOrganisation.email.email1 = this.email; else { email email = new email(); email.email1 = this.email; email.main = true; currentOrganisation.email = email; } } // Enregistre dans la base db.SaveChanges(); this.CloseActionFormEdit(); } }
public void actAdd(object obj) { bool error = false; this.validName = new Validation(); organisation organisation = new organisation(); // Validation nom de l'organisation if (!this.name.Equals("")) { organisation.name = this.name; this.validName.message = "Valide"; this.validName.valid = true; NotifyPropertyChanged("validName"); } else { this.validName.message = "Champ requis"; this.validName.valid = false; NotifyPropertyChanged("validName"); error = true; } if (!this.street.Equals("")) organisation.street = this.street; if (!this.city.Equals("")) organisation.city = this.city; if (!this.zip.Equals("")) organisation.zip = this.zip; if (!this.country.Equals("")) organisation.country = this.country; if (!this.phone.Equals("")) { phone phone = new phone(); phone.number = this.phone; phone.description = "main"; phone.main = true; organisation.phone = phone; } if (!this.email.Equals("")) { email email = new email(); email.email1 = this.email; email.main = true; organisation.email = email; } if (!error) { // Enregistre dans la base db.organisations.Add(organisation); db.SaveChanges(); mediator.NotifyViewModel(Helper.Event.ADD_ORGANISATION, organisation); this.CloseActionFormAdd(); } }
public void actAdd(object obj) { bool error = false; this.validFirstname = new Validation(); this.validLastname = new Validation(); contact customer = new contact(); // Validation prénom if (!this.firstname.Equals("")) { customer.firstname = this.firstname; this.validFirstname.message = "Valide"; this.validFirstname.valid = true; NotifyPropertyChanged("validFirstname"); } else { this.validFirstname.message = "Champ requis"; this.validFirstname.valid = false; NotifyPropertyChanged("validFirstname"); error = true; } // Validation nom if (!this.lastname.Equals("")) { customer.lastname = this.lastname; this.validLastname.message = "Valide"; this.validLastname.valid = true; NotifyPropertyChanged("validLastname"); } else { this.validLastname.message = "Champ requis"; this.validLastname.valid = false; NotifyPropertyChanged("validLastname"); error = true; } customer.street = this.street; customer.city = this.city; customer.zip = this.zip; customer.country = this.country; if (!this.phonePrivate.Equals("")) { phone phone = new phone(); phone.number = this.phonePrivate; phone.description = "private"; phone.main = true; customer.phones.Add(phone); } if (!this.phonePro.Equals("")) { phone phone = new phone(); phone.number = this.phonePro; phone.description = "pro"; phone.main = true; customer.phones.Add(phone); } if (!this.email.Equals("")) { email email = new email(); email.email1 = this.email; email.main = true; customer.emails.Add(email); } if (!error) { customer.add_date = DateTime.Now; customer.civility = civilities.ElementAt(civilityIndex).getValue(); // Enregistre dans la base db.contacts.Add(customer); db.SaveChanges(); mediator.NotifyViewModel(Helper.Event.ADD_CUSTOMER, customer); this.CloseActionFormAdd(); } }