} //end of Retrieve() public object RetrieveAll(Type type) { List <CustomerProps> list = new List <CustomerProps>(); DBDataReader reader = null; CustomerProps props; try { reader = RunProcedure("usp_CustomerSelectAll"); if (!reader.IsClosed) { while (reader.Read()) { props = new CustomerProps(); props.SetState(reader); list.Add(props); } } return(list); } catch (Exception e) { // log this exception throw; } finally { if (!reader.IsClosed) { reader.Close(); } } }
public void TestSetStateXML() { CustomerProps newC = new CustomerProps(); string xml = c.GetState(); newC.SetState(xml); Assert.AreEqual(newC.customerID, c.customerID); Assert.AreEqual(newC.name, c.name); }
public void TestSetState() { string xml = props1.GetState(); props2.SetState(xml); Assert.AreEqual(props1.name, props2.name); Assert.AreEqual(props1.address, props2.address); }
public void TestSetState() { string xml = p.GetState(); CustomerProps p2 = new CustomerProps(); p2.SetState(xml); Assert.AreEqual(p.name, p2.name); Assert.AreEqual(p.zip, p2.zip); Assert.AreEqual(p.state, p2.state); }
public void SetStateTest() { CustomerProps props2 = new CustomerProps(); props2.SetState(props.GetState()); Assert.AreEqual(props.ID, props2.ID); Assert.AreEqual(props.name, props2.name); Assert.AreEqual(props.address, props2.address); Assert.AreEqual(props.city, props2.city); Assert.AreEqual(props.state, props2.state); Assert.AreEqual(props.zipcode, props2.zipcode); Assert.AreEqual(props.ConcurrencyID, props2.ConcurrencyID); }
public void TestSetState() { string output = c.GetState(); CustomerProps newC = new CustomerProps(); newC.SetState(output); Assert.AreEqual(c.ID, newC.ID); Assert.AreEqual(c.Name, newC.Name); Assert.AreEqual(c.Address, newC.Address); Assert.AreEqual(c.City, newC.City); Assert.AreEqual(c.State, newC.State); Assert.AreEqual(c.ZipCode, newC.ZipCode); Assert.AreEqual(c.ConcurrencyID, newC.ConcurrencyID); }
public void TestSetState() { string cString = testc.GetState(); CustomerProps c2 = new CustomerProps(); c2.SetState(cString); Assert.AreEqual(testc.customerID, c2.customerID); Assert.AreEqual(testc.name, c2.name); Assert.AreEqual(testc.address, c2.address); Assert.AreEqual(testc.city, c2.city); Assert.AreEqual(testc.state, c2.state); Assert.AreEqual(testc.zipCode, c2.zipCode); Assert.AreEqual(testc.concurrencyID, c2.concurrencyID); }
} // end of Delete() // returns one object public IBaseProps Retrieve(Object key) { DBDataReader data = null; CustomerProps props = new CustomerProps(); DBCommand command = new DBCommand(); command.CommandText = "usp_CustomerSelect"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@CustomerID", SqlDbType.Int); command.Parameters["@CustomerID"].Value = (Int32)key; try { // creates data reader data = RunProcedure(command); // if data reader is not closed if (!data.IsClosed) { // if data reader is read if (data.Read()) { props.SetState(data); } else { throw new Exception("Record does not exist in the database."); } } return(props); } catch (Exception e) { // log this exception throw; } finally { if (data != null) { if (!data.IsClosed) { data.Close(); } } } } //end of Retrieve()