/// <summary> /// Check if dates of sales are close enough /// </summary> /// <returns><c>true</c>, if dates are close was checked, <c>false</c> otherwise.</returns> /// <param name="prevPricingData">Previous pricing data.</param> /// /// <param name="currentPricingData">Current pricing data.</param> private bool DatesAreClose(PricingData prevPricingData, PricingData currentPricingData) { int prevDateDiff = (currentPricingData.PriceDate - prevPricingData.PriceDate).Days; bool result = prevDateDiff > 0 && prevDateDiff < 8; return result; }
public List<PricingData> GetPricingForProduct(string productID, string storeID) { /* MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(); conn.ConnectionString = this->_conn; conn.Open(); */ List<PricingData> result = new List<PricingData> (); IDbConnection dbcon = new MySqlConnection(_connectionString); dbcon.Open(); string sql = "SELECT ShopID, ProductID, SaleDate, SalePrice, SaleVolume " + "from PriceLog " + "where ShopID = '" + storeID + "' and ProductID = '" + productID + "' order by SalePrice asc"; IDbCommand dbcmd = dbcon.CreateCommand(); dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader(); while(reader.Read()) { PricingData d = new PricingData (); d.SKU = (string) reader["ProductID"]; d.OutletName = (string)reader ["ShopID"]; d.Price = (decimal)reader ["SalePrice"]; d.Volume = (decimal)reader ["SaleVolume"]; d.PriceDate = (DateTime)reader ["SaleDate"]; result.Add (d); } // clean up reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbcon.Close(); dbcon = null; return result; }