public void SetContact(ContactDetails contactDetails) { if (Contact != null) Contact.ErrorsChanged -= RaiseCanExecuteChanged; _editingContact = contactDetails; Contact = new SimpleEditableContact(); Contact.ErrorsChanged += RaiseCanExecuteChanged; CopyContactDetails(_editingContact, Contact); }
private void CopyContactDetails(ContactDetails source, SimpleEditableContact target) { if (EditMode) { target.Id = source.Id; target.Name = source.Name; target.Surname = source.Surname; target.PhoneNumber = source.PhoneNumber; target.City = source.City; } }
private void OnEditContact(ContactDetails contact) { EditContactRequested(contact.Id); }
private ContactDetails GetContactDetails(int id) { ContactDetails contact = null; string cmdTxt = "SELECT Id, Name, Surname, City, PhoneNumber " + "FROM ContactDetails " + "WHERE Id = @Id"; using (var conn = new NpgsqlConnection(_conn)) using (var cmd = new NpgsqlCommand(cmdTxt, conn)) { conn.Open(); cmd.Parameters.Add(new NpgsqlParameter("@Id", id)); using (var results = cmd.ExecuteReader()) { while (results.Read()) { contact = new ContactDetails { Id = Int32.Parse(results["Id"].ToString()), Name = results["Name"].ToString(), Surname = results["Surname"].ToString(), City = results["City"].ToString(), PhoneNumber = results["PhoneNumber"].ToString() }; } } } return contact; }