/// <summary> /// Read all contacts /// </summary> /// <returns></returns> public List <Contact> Read() { var op = new ContactOperations(); var list = Convert(op.Read()); return(list); }
static void Main(string[] args) { var contact = new tbl_contact() { FirstName = "Joe", LastName = "Smith", Address = "123", PhoneNumber = "555", Birthday = new DateTime(1980, 1, 1) }; var op = new ContactOperations(); //op.Create(contact); //op.Update(2, contact); op.Delete(2); var list = op.Read(); foreach (var elem in list) { Console.WriteLine($"{elem.FirstName} {elem.LastName} {elem.Address} {elem.PhoneNumber} {elem.Birthday}"); } // Pause at the end Console.Read(); }
/// <summary> /// Delete a contact by ID /// </summary> /// <param name="id"></param> public void Delete(int id) { if (id < 1) { return; } var op = new ContactOperations(); op.Delete(id); }
/// <summary> /// Read a contact by their ID /// </summary> /// <param name="id"></param> /// <returns></returns> public Contact ReadById(int id) { // return a blank contact if (id < 1) { return(new Contact()); } var op = new ContactOperations(); var item = Convert(op.ReadById(id)); return(item); }
/// <summary> /// Create a new contact /// </summary> /// <param name="contact"></param> public void Create(Contact contact) { // Cannot create an invalid contact if (object.ReferenceEquals(contact, null)) { throw new ArgumentException( $"Contacts cannot be created with a null reference."); } var op = new ContactOperations(); contact.FirstName = contact.FirstName.Trim(); contact.LastName = contact.LastName.Trim(); contact.Address = contact.Address.Trim(); contact.PhoneNumber = contact.PhoneNumber.Trim(); op.Create(Convert(contact)); }
/// <summary> /// Update a contact by ID /// </summary> /// <param name="id"></param> /// <param name="contact"></param> public void Update(int id, Contact contact) { // return without updating for invalid arguments if (id < 1) { return; } if (object.ReferenceEquals(contact, null)) { return; } var op = new ContactOperations(); contact.FirstName = contact.FirstName.Trim(); contact.LastName = contact.LastName.Trim(); contact.Address = contact.Address.Trim(); contact.PhoneNumber = contact.PhoneNumber.Trim(); op.Update(id, Convert(contact)); }
public async Task DecryptConnectionString() { var contacts = await ContactOperations.GetContactsAsync(); Assert.IsTrue(contacts.Count == 91); }
public async Task TestEntityFramework6() { var contacts = await ContactOperations.GetContactsAsync(); Assert.IsTrue(contacts.Count == 91); }