예제 #1
0
        public ProductViewModel GetProductViewModel()
        {
            var categories = _context.Categories.ToList();
            var districts  = _context.Districts.ToList();
            var domains    = _context.Categories.Select(c => c.Domain).Distinct().ToList();

            CartService cs         = new CartService(_httpContextAccessor, _context);
            var         totalPrice = cs.GetCartTotalPrice();
            var         cartCount  = cs.GetCartCount();
            var         viewmodel  = new ProductViewModel
            {
                District    = districts,
                Category    = categories,
                DistinctCat = domains,
                CartCount   = cartCount,
                TotalPrice  = totalPrice,
                Sellers     = _context.Sellers.ToList()
            };


            return(viewmodel);
        }
예제 #2
0
        public ProductViewModel ProductVMWithCartCount(int id)
        {
            var products = GetProductByCategoryID(id);

            var all = GetAllProducts();

            var categories = GetAllCategories();
            var districts  = GetAllDistricts();
            var domains    = GetCategoryByDomain();

            var cartCount   = cartService.GetCartCount();
            var productView = new ProductViewModel
            {
                Products    = products,
                Category    = categories,
                District    = districts,
                DistinctCat = domains,
                BaseProduct = all,  //all variable is created because //it will always remain same as it is inherited
                CartCount   = cartCount
            };

            return(productView);
        }