Exemple #1
0
        /// <summary>
        /// This method return receipt to accept.
        /// </summary>
        /// <param name="familyID">family the receipt belongs to</param>
        /// <param name="receiptToUpdate">receipt we need to return to accept</param>
        public void ReturnReceiptToAccept(string familyID, ReceiptToReturn receiptToUpdate)
        {
            //first we update status to -1
            DBConnection.UpdateStatus(familyID, receiptToUpdate.receiptID, "-1");
            string marketId = receiptToUpdate.marketID;

            //than we need to find similar products
            foreach (MetaData product in receiptToUpdate.products)
            {
                string productId = product.getsID();
                if (DBConnection.SelectQuery("select SID from OptionalProducts AS OP WHERE OP.MarketID='" + marketId + "' AND OP.ProductID ='" + productId + "'").Count == 0)
                {
                    List<ResearchProduct> optionalProducts = jwd.GetTopFiveSimilarProducts(product.description);
                    DBConnection.InsertOptionalProducts(marketId, productId, optionalProducts);
                }
            }

            //after finished, set status to 0
            DBConnection.UpdateStatus(familyID, receiptToUpdate.receiptID, "0");
        }