예제 #1
0
        public VMProducts ProductsModel()
        {
            VMProducts vm = new VMProducts();

            vm.Products = new List <CommonProduct>();

            foreach (var p in dbContext.Products.Include("Size").GroupBy(x => new { x.Size.ID, x.Size.Name, x.Size.Width, x.Size.Height }))
            {
                CommonProduct c = new CommonProduct();
                c.SizeID   = p.Key.ID;
                c.SizeName = p.Key.Name;
                c.Width    = (int)p.Key.Width;
                c.Height   = (int)p.Key.Height;
                c.Colors   = new List <string>();
                c.Img      = dbContext.Products.Where(y => y.SizeID == p.Key.ID).FirstOrDefault().Img;

                foreach (var s in dbContext.Products.Include("Size").Where(y => y.Size.Name == c.SizeName))
                {
                    c.Colors.Add(s.Color);

                    foreach (var g in s.Size.Games)
                    {
                        c.Games = new List <string>();

                        c.Games.Add(g.Name);
                    }
                }


                vm.Products.Add(c);
            }


            return(vm);
        }
        public IActionResult LoadMoreProducts(int skip, string lang)
        {
            ViewBag.lang = lang;
            VMProducts model    = new VMProducts();
            var        products = _context.Products.Include(p => p.ProductPhotos).Where(p => p.IsActive == true).Skip(skip).Take(4).ToList();

            return(PartialView("_ProductsPartial", products));
        }
예제 #3
0
        public ActionResult Products()
        {
            VMProducts model = new VMProducts();

            model = service.ProductsModel();

            return(View(model));
        }
        public IActionResult Products(string lang)
        {
            ViewBag.lang = lang;
            ViewBag.TotalCountProducts = _context.Products.Where(p => p.IsActive == true).Count();
            VMProducts model = new VMProducts();

            model.Products   = _context.Products.Include(p => p.ProductCategory).Include(p => p.ProductPhotos).Where(p => p.IsActive == true).OrderBy(p => p.ID).Take(4).ToList();
            model.Categories = _context.ProductCategories.OrderBy(c => c.CategoryName).ToList();
            return(View(model));
        }