Example #1
0
        public ProductsPageModel GetProductsByCata(int catagoryID)
        {
            ProductsPageDAL dal = new ProductsPageDAL();
            DataTable       dt  = dal.getProductByCatagorie(catagoryID);

            // converting from a DataTable to a Product Object!
            ProductsPageModel   d            = new ProductsPageModel();
            string              CDescription = "";
            List <ProductModel> products     = new List <ProductModel>();

            foreach (DataRow dr in dt.Rows)
            {
                ProductModel product = new ProductModel();
                product.ProductID          = (int)dr["ProductID"];
                product.ProductName        = dr["ProductName"].ToString();
                product.ProductImage       = dr["ProductImage"].ToString();
                product.ProductPrice       = (int)dr["ProductPrice"];
                product.ShipperID          = dr["ShipperID"].ToString();
                product.ProductDescription = dr["ProductDescription"].ToString();
                product.CategoryId         = catagoryID;
                products.Add(product);
                product.CatagoryDescription = dr["CatagoryDescription"].ToString();
                product.CatagoryName        = dr["CatagoryName"].ToString();
                CDescription = product.CatagoryDescription;
            }
            d.Products            = products;
            d.CatagoryDescription = CDescription;
            return(d);
        }
Example #2
0
        public ProductsPageModel SearchProducts(string productName)
        {
            ProductsPageDAL   dal = new ProductsPageDAL();
            DataTable         dt  = dal.GetProductByName(productName);
            ProductsPageModel d   = new ProductsPageModel();

            d.Products = GetProducts(dt);
            return(d);
        }
Example #3
0
        public ProductsPageModel GetProductsList()
        {
            ProductsPageDAL dal = new ProductsPageDAL();
            DataTable       dt  = dal.getProducts();

            // converting from a DataTable to a Product Object!
            ProductsPageModel   d        = new ProductsPageModel();
            List <ProductModel> products = new List <ProductModel>();

            foreach (DataRow dr in dt.Rows)
            {
                ProductModel product = new ProductModel();
                product.ProductID          = (int)dr["ProductID"];
                product.ProductName        = dr["ProductName"].ToString();
                product.ProductImage       = dr["ProductImage"].ToString();
                product.ProductPrice       = (int)dr["ProductPrice"];
                product.ProductDescription = dr["ProductDescription"].ToString();
                products.Add(product);
            }
            d.Products = products;
            return(d);
        }