public string CreateContact(CreateContactCommand contact) { ContactDTO contact1 = new ContactDTO(); contact1.Id = Guid.NewGuid().ToString(); contact1.Name = contact.Name; contact1.Addr = contact.Addr; 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); }
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 string UpdateContact(ContactDTO contact) { throw new NotImplementedException(); }
public string CreateContact(ContactDTO contact) { contacts.Add(contact); return(contact.Id); }