public IHttpActionResult AddContact(Contact contact) { var repo = new AccountRepositoryADO(); try { repo.InsertContact(contact); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void CanInsertContacts() { var repo = new AccountRepositoryADO(); var contact = new Contact(); contact.Name = "Test"; contact.Phone = "1234567890"; contact.Message = "Testing"; contact.Email = "Test"; repo.InsertContact(contact); var Type = repo.GetContact(3); Assert.AreEqual("Test", Type.Name); Assert.AreEqual("Test", Type.Email); Assert.AreEqual("Testing", Type.Message); Assert.AreEqual("1234567890", Type.Phone); }
public IHttpActionResult AddContact(string Name, string Email, string Phone, string Message) { var repo = new AccountRepositoryADO(); Contact contact = new Contact(); contact.Email = Email; contact.Message = Message; contact.Name = Name; contact.Phone = Phone; try { repo.InsertContact(contact); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void CanDeleteContact() { var repo = new AccountRepositoryADO(); var contact = new Contact(); contact.Name = "Test"; contact.Phone = "1234567890"; contact.Message = "Testing"; contact.Email = "Test"; repo.InsertContact(contact); var load = repo.GetContact(3); Assert.IsNotNull(load.Name); repo.DeleteContact(3); load = repo.GetContact(3); Assert.IsNull(load.Name); }