예제 #1
0
 public ActionResult ProductList()
 {
     //if (!CommonFile.IsUserAuthenticate(this.ControllerContext.HttpContext))
     //{
     //    return RedirectToAction("Index", "Login");
     //}
     ViewBag.UsersProduct = CommonFile.GetProduct();
     return(View());
 }
예제 #2
0
 public ActionResult Index()
 {
     if (ListAllProduct == null)
     {
         ListAllProduct = CommonFile.GetProduct();
     }
     var PopularProducts = CommonFile.GetPopularProduct(0);
     ViewBag.PopularProducts = PopularProducts;
     ViewBag.FirstCategory = PopularProducts.Where(x => x.ParentCatId == long.Parse((Constant.ParentCategories[0]).ToString())).Take(Constant.NumberOfProductsInFrontPage);
     ViewBag.SecondCategory = PopularProducts.Where(x => x.ParentCatId == Constant.ParentCategories[1]).Take(Constant.NumberOfProductsInFrontPage);
     ViewBag.ThirdCategory = PopularProducts.Where(x => x.ParentCatId == Constant.ParentCategories[2]).Take(Constant.NumberOfProductsInFrontPage);
     ViewBag.FourthCategory = PopularProducts.Where(x => x.ParentCatId == Constant.ParentCategories[3]).Take(Constant.NumberOfProductsInFrontPage);
     ViewBag.FifthCategory = PopularProducts.Where(x => x.ParentCatId == Constant.ParentCategories[4]).Take(Constant.NumberOfProductsInFrontPage);
     ViewBag.ProductCatList = CommonFile.GetProductCategory(null);
     return View();
 }
예제 #3
0
 // GET: Product
 public ActionResult Index()
 {
     ViewBag.AllProduct = CommonFile.GetProduct();
     return(View());
 }
        public ActionResult Index(string id)
        {
            long?Id = Convert.ToInt64(CommonFile.Decode(id));

            Services.SetCookie(this.ControllerContext.HttpContext, "ProductCatId", id.ToString());
            ListAllProduct = CommonFile.GetProduct();
            ProductModel objmodel          = new ProductModel();
            var          SearchProductList = new List <ProductModel>();

            if (!CommonFile.IsParentCategory(Id))
            {
                SearchProductList = ListAllProduct.Where(x => x.ProductCatId == Id).ToList();
            }
            else
            {
                SearchProductList = ListAllProduct.Where(x => x.ParentCatId == Id).ToList();
            }
            ViewBag.SearchCatId       = id;
            ViewBag.UsersProduct      = SearchProductList;
            ViewBag.SearchResultCount = SearchProductList.Count;
            var ProductCatList    = CommonFile.GetProductCategory(null);
            var EncodedCategories = new List <DropDownModel>();

            foreach (var item in ProductCatList)
            {
                DropDownModel dropDown = new DropDownModel();
                dropDown.Name         = item.Name;
                dropDown.Id           = item.Id;
                dropDown.EncodedId    = CommonFile.Encode(item.Id.ToString());
                dropDown.CatIdEncoded = CommonFile.Encode(item.ParentCatId.ToString());
                dropDown.ParentCatId  = item.ParentCatId;
                EncodedCategories.Add(dropDown);
            }
            int pageindex = 1;

            ViewBag.UsersProduct      = SearchProductList.Skip((pageindex - 1) * Constant.NumberOfProducts).Take(Constant.NumberOfProducts);
            ViewBag.LowerLimit        = ((pageindex / 5) * 5) + 1;
            ViewBag.PageIndex         = pageindex;
            ViewBag.ProductsFrom      = ((pageindex - 1) * Constant.NumberOfProducts);
            ViewBag.ToProductsCount   = Enumerable.Count(ViewBag.UsersProduct);
            ViewBag.SearchResultCount = SearchProductList.Count;
            ViewBag.LowerLimit        = 1;
            int nop         = SearchProductList.Count / Constant.NumberOfProducts;
            int remindernop = SearchProductList.Count % 12;

            if (nop < Constant.NumberOfPages)
            {
                if (remindernop > 0)
                {
                    nop = nop + 1;
                }
                ViewBag.NumberOfPages = nop;
            }
            else
            {
                ViewBag.NumberOfPages = Constant.NumberOfPages;
            }
            var ProductCategory = ProductCatList.Where(x => x.Id.Equals(Id));

            ViewBag.ProductCatList = EncodedCategories.Where(x => x.ParentCatId == ProductCategory.Single().ParentCatId);
            if (!CommonFile.IsParentCategory(Id))
            {
                objmodel.ParentCatId = ProductCategory.Single().ParentCatId;
            }
            else
            {
                objmodel.ParentCatId = ProductCategory.Single().Id;
            }
            objmodel.CategoryName = ProductCategory.Single().Name;
            return(View(objmodel));
        }