private void OnSave(object obj) { if (string.IsNullOrEmpty(NewCustomerContact.Name) || NewCustomerContact.Name.Length < 2) { ShowError(Resources.TXT_CUSTOMER_SETTINGS_ENTER_CUSTOMER_NAME); return; } var customerContact = NewCustomerContact.Clone <CustomerContact>(); if (IsEditing && SelectedIndex > -1) { CustomerContacts[SelectedIndex] = customerContact; } else { CustomerContacts.Add(customerContact); } Reset(); Repository.AddOrUpdate(customerContact); Saved(customerContact); CustomerContacts.Clear(); CustomerContacts.AddRange(Repository.GetAll().OrderBy(c => c.Name)); }
private void OnNewCustomerSelected(ModalClosedEventArgs e) { if (e.Saved) { CustomerContacts.Add((CustomerContact)e.Parameter); CustomerContact[] sorted = CustomerContacts.OrderBy(c => c.Name).ToArray(); CustomerContacts.Clear(); foreach (CustomerContact item in sorted) { CustomerContacts.Add(item); if (item == e.Parameter) { SelectedCustomerContact = item; } } } }