Beispiel #1
0
        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));
        }
Beispiel #2
0
        public bool DelecteContactById(string id)
        {
            ContactDTO contact = contacts.Find(x => x.Id == id);

            if (contact != null)
            {
                contacts.Remove(contact);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public string UpdateContact(ContactDTO contact)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public string CreateContact(ContactDTO contact)
 {
     contacts.Add(contact);
     return(contact.Id);
 }