public string CreateContact(CreateContactCommand contact) { ContactDTO contact1 = new ContactDTO(); contact1.Id = Guid.NewGuid().ToString(); contact1.Name = contact.Name; contact1.Address = contact.Address; contact1.Phone = contact.Phone; return(dal.CreateContact(contact1)); }
public bool DelecteContactById(string id) { ContactDTO contact = contacts.Find(x => x.Id == id); if (contact != null) { contacts.Remove(contact); return(true); } return(false); }
public string CreateContact(ContactDTO contact) { string text = string.Format("INSERT INTO contacts(id, name, phone, address) VALUES('{0}', '{1}', '{2}', '{3}')" , contact.Id, contact.Name, contact.Phone, contact.Addr); ExecuteNonQuery(text); return(contact.Id); }
private void UpdateContact(object sender, EventArgs e) { int row = Convert.ToInt32(bindingNavigatorPositionItem.Text) - 1; var text = dataGridView1.Rows[row]; ContactDTO contact = new ContactDTO(); contact.Id = text.Cells[0].Value.ToString(); contact.Name = text.Cells[1].Value.ToString(); contact.Phone = text.Cells[2].Value.ToString(); contact.Address = text.Cells[3].Value.ToString(); bll.UpdateContact(contact); }
public string CreateContact(ContactDTO contact) { var text = string.Format("INSERT INTO contacts(id, name, phone, address) " + "VALUES('{0}', '{1}', '{2}', '{3}');", contact.Id, contact.Name, contact.Phone, contact.Address); ExecuteNonQuery(text); MessageBox.Show("Contact Created!"); return(contact.Id); }
public bool UpdateContact(ContactDTO contact) { var command = string.Format("UPDATE contacts SET id = " + "\"{0}\", name = \"{1}\", " + "phone = \"{2}\", " + "address = \"{3}\" " + "WHERE id = \"{0}\"", contact.Id, contact.Name, contact.Phone, contact.Address); ExecuteNonQuery(command); MessageBox.Show("Update of contact with id:" + contact.Id); return(true); }
public List <ContactDTO> GetContacts(string selectSQL) { List <ContactDTO> res = new List <ContactDTO>(); using (SQLiteCommand command = new SQLiteCommand(selectSQL, connection)) { var reader = command.ExecuteReader(); while (reader.Read()) { var item = new ContactDTO { Id = reader.GetString(0), Name = reader.GetString(1), Phone = reader.GetString(2), Address = reader.GetString(3) }; res.Add(item); } } return(res); }
public List <ContactDTO> GetAllContacts() { List <ContactDTO> res = new List <ContactDTO>(); string selectSql = @"select * from contacts"; using (SQLiteCommand command = new SQLiteCommand(selectSql, con)) { var reader = command.ExecuteReader(); while (reader.Read()) { var item = new ContactDTO { Id = reader.GetString(0), Name = reader.GetString(1), Phone = reader.GetString(2), Addr = reader.GetString(3) }; res.Add(item); } } return(res); }
public bool UpdateContact(ContactDTO contact) { throw new NotImplementedException(); }
public string CreateContact(ContactDTO contact) { contacts.Add(contact); return(contact.Id); }
public bool UpdateContact(ContactDTO contact) { return(dal.UpdateContact(contact)); }