Exemple #1
0
        // ------------------------------------------------
        public Product(int productID)
        {
            IDal dal = DalFactory.GetDAL(GetType().Name);
            string query = "sp_GetProduct";

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("@ProductID", productID.ToString());

            var result = dal.RunQuery("VBase", query, parameters, true);

            if(result.Count == 1)
            {
                ID = productID;

                Dictionary<string, string> row = result[0];

                try
                {
                    int iTemp;
                    double dblTemp;

                    UPC = row["UPC"];
                    Name = row["Name"];
                    BrandName = row["BrandName"];
                    CompanyID = int.TryParse(row["Company_id"], out iTemp) ? iTemp : -1;
                    CaseCapacity = int.TryParse(row["CaseCapacity"], out iTemp) ? iTemp : -1;
                    UnitWholesale = Double.TryParse(row["UnitWholesale"], out dblTemp) ? dblTemp : 0.0;

                    // ------------------------------------
                    // The Category ID is stored in the DB.
                    // Here we will go get the actual Category object.

                    if(int.TryParse(row["Category_id"], out iTemp))
                    {
                        Category = new ProductCategory(iTemp);
                    }
                }
                catch(ArgumentNullException /*exp*/)
                {
                    // Revisit logging.
                }
                catch(FormatException /*exp*/)
                {
                    // Revisit logging.
                }
                catch(Exception /*exp*/)
                {
                    // Revisit logging.
                }
            }
        }
Exemple #2
0
        public void ProductCategory()
        {
            string name = Convert.ToString(TestContext.DataRow["Name"]);
            int categoryID = Convert.ToInt32(TestContext.DataRow["CategoryID"]);
            string description = Convert.ToString(TestContext.DataRow["Description"]);

            ProductCategory prodCat = new ProductCategory(categoryID);

            Assert.AreEqual(name, prodCat.Name);
            Assert.AreEqual(categoryID, prodCat.ID);
            Assert.AreEqual(description, prodCat.Description);
        }