public override object Execute() { foreach (NewCriteria <T> criteria in _criterias) { if (criteria != null) { switch (criteria.Criteria) { case Utilites.QueryCriteria.ID: CustomerAccess.GetCustomersByID(Convert.ToInt32(criteria.First)); break; case Utilites.QueryCriteria.Bithday: if (criteria.Predicate == "Between") { CustomerAccess.GetCustomersByBirthdayBetween(Convert.ToDateTime(criteria.First), Convert.ToDateTime(criteria.Second)); } else { CustomerAccess.GetCustomersByBirthOfDay(Convert.ToDateTime(criteria.First), criteria.Predicate); } break; default: CustomerAccess.GetDataByCriteria(criteria.Criteria, criteria.Values.Cast <object>().ToArray(), criteria.Predicate); break; } } } return(CustomerAccess.GetData()); }
public void CustomerAccess_GetByAddress_TestMethod(string addr) { SqlConnection connection = ConnectionManager.Connection; connection.Open(); CustomerAccess.FillDictionary(); CustomerAccess.FillCustomerData(); CustomerAccess.GetDataByCriteria("Address", new[] { "Славянск", addr }); DataSet dataSet = (DataSet)CustomerAccess.GetData(); Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0); }
public void CustomerAccess_GetDataByCriteria_TestMethod(string lastname1, string addr1, string lastName2, string addr2) { SqlConnection connection = ConnectionManager.Connection; connection.Open(); CustomerAccess.FillDictionary(); CustomerAccess.FillCustomerData(); CustomerAccess.GetDataByCriteria("LastName", new[] { lastname1 }, "="); CustomerAccess.GetDataByCriteria("Address", new [] { "Славянск", addr1 }, "="); CustomerAccess.GetDataByCriteria("LastName", new[] { lastName2, }, "="); CustomerAccess.GetDataByCriteria("Address", new[] { "Славянск", addr2 }, "="); DataSet dataSet = (DataSet)CustomerAccess.GetData(); Assert.IsTrue(dataSet.Tables["Customer"].Rows.Count > 0); }
public object FindBy(string criteria, params object[] values) { CustomerAccess.GetDataByCriteria(criteria, values); return(CustomerAccess.GetData()); }