public void ProductCounterTest() { var productPageInstance = ProductCategoryPage.NavigateTo(base.Driver); var products = productPageInstance.GetProducts(); products[1].AddToCartButton.Click(); Thread.Sleep(5000); //productPageInstance = PageFactoryExtensions.InitPage<ProductCategoryPage>(this.Driver); var countAsAString = productPageInstance.ProductCountTextBox.Text; var countAsAnInteger = Convert.ToInt32(countAsAString); Assert.AreEqual(1, countAsAnInteger); }
public ActionResult Market(string pMarketName = "") { V308CMSEntities mEntities = new V308CMSEntities(); ProductRepository productRepository = new ProductRepository(mEntities); MarketRepository marketRepository = new MarketRepository(mEntities); Market mMarket; ProductCategoryPageBox mProductCategoryPageBox = new ProductCategoryPageBox(); ProductType mProductType = new ProductType(); List <ProductType> mProductTypeList; try { //lay chi tiet ProductType //lay danh sach các nhóm sản phẩm con //lay cac san pham cua nhom mMarket = marketRepository.getByName(pMarketName.Replace('-', ' ')); if (mMarket != null) { mProductCategoryPageBox.List = new List <ProductCategoryPage>(); mProductCategoryPageBox.Market = mMarket; mProductTypeList = productRepository.getProductTypeParent(); foreach (ProductType it in mProductTypeList) { ProductCategoryPage mProductPage = new ProductCategoryPage(); mProductPage.Name = it.Name; mProductPage.Value = mMarket.UserName; mProductPage.Id = (int)it.ID; mProductPage.Image = it.Image; List <Product> mProductList = productRepository.getByPageSizeMarketId(1, 4, (int)it.ID, mMarket.ID, it.Level); mProductPage.List = mProductList; mProductCategoryPageBox.List.Add(mProductPage); } } return(View(mProductCategoryPageBox)); } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } finally { mEntities.Dispose(); productRepository.Dispose(); } }
public ActionResult MarketCategory(string pMarketName = "", int pGroupId = 0, int pPage = 1) { V308CMSEntities mEntities = new V308CMSEntities(); ProductRepository productRepository = new ProductRepository(mEntities); MarketRepository marketRepository = new MarketRepository(mEntities); Market mMarket; ProductCategoryPage mProductPage = new ProductCategoryPage(); ProductType mProductType = new ProductType(); try { //lay chi tiet ProductType //lay danh sach các nhóm sản phẩm con //lay cac san pham cua nhom mMarket = marketRepository.getByName(pMarketName.Replace('-', ' ')); mProductType = productRepository.LayLoaiSanPhamTheoId(pGroupId); if (mMarket != null) { mProductPage.Market = mMarket; mProductPage.Name = mProductType.Name; mProductPage.Id = mProductType.ID; mProductPage.Image = mProductType.Image; List <Product> mProductList = productRepository.getByPageSizeMarketId(1, 25, mProductType.ID, mMarket.ID, mProductType.Level); mProductPage.List = mProductList; if (mProductList.Count < 25) { mProductPage.IsEnd = true; } mProductPage.Page = pPage; } return(View(mProductPage)); } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } finally { mEntities.Dispose(); productRepository.Dispose(); } }
public static ProductCategoryPage GetCategoryPage(ProductType ProductCategory, int nPage = 1, bool includeProductImages = false) { CreateRepos(); ProductCategoryPage ModelPage = new ProductCategoryPage(); try{ ModelPage.Name = ProductCategory.Name; ModelPage.Id = (int)ProductCategory.ID; ModelPage.Image = ProductCategory.Image; var products = from p in mEntities.Product where p.Type == ProductCategory.ID && p.Status == true orderby p.ID descending select p ; ModelPage.ProductTotal = products.Count(); if (nPage * ProductShowLimit > ModelPage.ProductTotal) { nPage = 1; } ModelPage.Paging = ModelPage.ProductTotal > ProductShowLimit; ModelPage.List = products.Skip((nPage - 1) * ProductShowLimit).Take(ProductShowLimit).ToList();; } catch (Exception ex) { Console.Write(ex); } finally { DisposeRepos(); } return(ModelPage); }
public ActionResult Category(int pGroupId = 0, int pPage = 1) { V308CMSEntities mEntities = new V308CMSEntities(); ProductRepository productRepository = new ProductRepository(mEntities); MarketRepository marketRepository = new MarketRepository(mEntities); ProductCategoryPageContainer mProductCategoryPageContainer = new ProductCategoryPageContainer(); List <ProductCategoryPage> mProductPageList = new List <ProductCategoryPage>(); ProductType mProductType = new ProductType(); List <ProductType> mProductTypeList; List <ProductType> mSoCheList; List <Product> mBestBuyList; List <Product> mProductList = new List <Product>(); try { //lay chi tiet ProductType //lay danh sach các sieu thi co loai san pham nay //lay cac san pham cua nhom do mProductType = productRepository.LayLoaiSanPhamTheoId(pGroupId); if (mProductType != null) { ViewBag.Id = mProductType.ID; ViewBag.Name = mProductType.Name; ViewBag.Level = mProductType.Level; ViewBag.TypeBanner = mProductType.TypeBanner; //lay danh sach sieu thi ban loai san pham nay if (mProductType.Parent == 0) { mProductTypeList = productRepository.getProductTypeByProductType(mProductType.ID);//lay danh sach cap 1 } else { mProductTypeList = new List <ProductType>(); mProductTypeList.Add(mProductType); //mProductTypeList = productRepository.getProductTypeByProductType((int)mProductType.Parent);//lay danh sach cap 2 } //lay các san pham cua nhom nay if (mProductTypeList.Count > 0) { foreach (ProductType it in mProductTypeList) { //Chi tiết market ProductCategoryPage mProductPage = new ProductCategoryPage(); mProductPage.Name = it.Name; mProductPage.Id = (int)it.ID; mProductPage.Image = it.Image; if (mProductType.Parent == 0) { mProductList = productRepository.LayTheoTrangAndType(1, 4, it.ID, it.Level); } else { mProductList = productRepository.LayTheoTrangAndType(1, 40, it.ID, it.Level); } mProductPage.List = mProductList; mProductPageList.Add(mProductPage); } } else { ProductCategoryPage mProductPage = new ProductCategoryPage(); mProductPage.Name = mProductType.Name; mProductPage.Id = (int)mProductType.ID; mProductPage.Image = mProductType.Image; mProductList = productRepository.LayTheoTrangAndType(1, 40, mProductType.ID, mProductType.Level); mProductPage.List = mProductList; mProductPageList.Add(mProductPage); } //lay danh sach cac nhom so che mSoCheList = productRepository.LayProductTypeTheoParentId(147); mProductCategoryPageContainer.ProductTypeList = mSoCheList; //lay cac san pham ban chay mBestBuyList = productRepository.getBestBuyWithType(1, 10, 147, "10030"); mProductCategoryPageContainer.ProductList = mBestBuyList; } mProductCategoryPageContainer.List = mProductPageList; mProductCategoryPageContainer.ProductType = mProductType; if (mProductList.Count < 40) { mProductCategoryPageContainer.IsEnd = true; } mProductCategoryPageContainer.Page = pPage; //lay chi tiet san pham if (!Request.Browser.IsMobileDevice) { return(View(mProductCategoryPageContainer)); } else { return(View("~/Views/Home/MobileCategory.cshtml", mProductCategoryPageContainer)); } } catch (Exception ex) { return(Content(ex.InnerException.ToString())); } finally { mEntities.Dispose(); productRepository.Dispose(); } }