예제 #1
0
        public ActionResult RecentProducts(int?productID, int pageSize = 0)
        {
            if (pageSize == 0)
            {
                pageSize = ConfigurationsHelper.FrontendRecordsSizePerPage;
            }

            HttpCookie LangCookie           = Request.Cookies["LangCookie"];
            FeaturedProductsViewModel model = new FeaturedProductsViewModel();

            model.Products = ProductsService.Instance.SearchProducts(null, null, null, null, null, 1, pageSize);

            if (LangCookie != null)
            {
                if (LangCookie.Value == "ar")
                {
                    foreach (var elem in model.Products.ToList())
                    {
                        elem.Name          = elem.ArName;
                        elem.Description   = elem.ArDescription;
                        elem.Summary       = elem.ArSummary;
                        elem.Category.Name = elem.Category.ArName;
                    }
                }
            }



            return(PartialView("_RecentProducts", model));
        }
예제 #2
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            FeaturedProductsViewModel model = new FeaturedProductsViewModel();

            model.Items = PrepProducts(app.CatalogServices.Products.FindFeatured(1, 100), app);
            return(RenderModel(model, app));
        }
예제 #3
0
        //
        // GET: /ContentBlocks/FeaturedProducts/
        public ActionResult Index(ContentBlock block)
        {
            FeaturedProductsViewModel model = new FeaturedProductsViewModel();

            model.Items = PrepProducts(MTApp.CatalogServices.Products.FindFeatured(1, 100));
            return(View(model));
        }
예제 #4
0
        public void ProductsIsNotNull()
        {
            // Act
            var sut = new FeaturedProductsViewModel(Enumerable.Empty <ProductViewModel>());

            // Assert
            Assert.NotNull(sut.Products);
        }
        public ViewResult Index()
        {
            IEnumerable <DiscountedProduct> featuredProducts = this.productService.GetFeaturedProducts(); //tutaj powinno być podmienione

            var vm = new FeaturedProductsViewModel(from product in featuredProducts select new ProductViewModel(product));

            return(this.View(vm));
        }
        public IActionResult Index()
        {
            IEnumerable <DiscountedProduct> products =
                this.productService.GetFeaturedProducts();

            var vm = new FeaturedProductsViewModel(products.Select(e => new ProductViewModel(e)));

            return(View(vm));
        }
        public ActionResult Index(ContentBlock block)
        {
            var model = new FeaturedProductsViewModel
            {
                Items = PrepProducts(HccApp.CatalogServices.Products.FindFeatured(1, 100))
            };

            return(View(model));
        }
        public IActionResult Index()
        {
            IEnumerable <DiscountedProduct> products = _productService.GetFeaturedProducts();
            var vm = new FeaturedProductsViewModel(
                from product in products
                select new ProductViewModel(product));

            return(this.View(vm));
        }
 //
 // GET: /ContentBlocks/FeaturedProducts/
 public ActionResult Index(ContentBlock block)
 {
     var profiler = MvcMiniProfiler.MiniProfiler.Current;
     using (profiler.Step("Block:FeaturedProducts"))
     {
         FeaturedProductsViewModel model = new FeaturedProductsViewModel();
         model.Items = PrepProducts(MTApp.CatalogServices.Products.FindFeatured(1, 100));
         return View(model);
     }
 }
예제 #10
0
        public ActionResult Index()
        {
            var model = new FeaturedProductsViewModel();

            var productService = new ProductService(_repository);
            var featuredProducts = productService.GetFeaturedProducts(User);
            foreach (var product in featuredProducts)
            {
                var productViewModel = new ProductViewModel(product);
                model.Products.Add(productViewModel);
            }
            return View(model);
        }
예제 #11
0
        public ActionResult Index()
        {
            var productService = new ProductService(this.repository);

            var vm = new FeaturedProductsViewModel();

            var products = productService.GetFeaturedProducts(this.User);

            foreach (var product in products)
            {
                var productVM = new ProductViewModel(product);
                vm.Products.Add(productVM);
            }
            return(View(vm));
        }
예제 #12
0
        private string RenderModel(FeaturedProductsViewModel model, MerchantTribeApplication app)
        {
            StringBuilder sb = new StringBuilder();

            var productRenderer = new code.TemplateEngine.TagHandlers.SingleProduct();

            sb.Append("<div class=\"featuredproducts\">");
            foreach (var p in model.Items)
            {
                sb.Append(productRenderer.RenderModelToString(p, app));
            }
            sb.Append("<div class=\"clear\"></div>");
            sb.Append("</div>");

            return(sb.ToString());
        }
예제 #13
0
        public ActionResult Index()
        {
            var productService = new ProductService(this.productRepository);

            var viewModel = new FeaturedProductsViewModel();

            IEnumerable <DiscountedProduct> products = productService.GetFeaturedProducts(this.User);

            foreach (DiscountedProduct product in products)
            {
                var productViewModel = new ProductViewModel(product);
                viewModel.Products.Add(productViewModel);
            }

            return(this.View(viewModel));
        }
예제 #14
0
        public IActionResult Index()
        {
            System.DateTime start = System.DateTime.Now;
            //Thread.Sleep(3000);

            var model = new FeaturedProductsViewModel
            {
                FeaturedProducts = new DataView(dataLayer.GetFeaturedProducts()),
            };

            System.DateTime end = System.DateTime.Now;
            ViewData["StartTime"]     = start.ToLongTimeString();
            ViewData["ExecutionTime"] = end.Subtract(start).Seconds + "." + end.Subtract(start).Milliseconds;

            return(View(model));
        }
예제 #15
0
        public ViewResult Index()
        {
            var productService =
                new ProductService(this.repository);

            var vm = new FeaturedProductsViewModel();

            var products =
                productService.GetFeaturedProducts(this.User);
            foreach (var product in products)
            {
                var productVM = new ProductViewModel(product);
                vm.Products.Add(productVM);
            }

            return View(vm);
        }
예제 #16
0
        //[OutputCache(Duration = 1000, VaryByParam = "productID;pageSize")]
        public ActionResult FeaturedProducts(int?productID, int pageSize = 0, bool isForHomePage = false)
        {
            if (pageSize == 0)
            {
                pageSize = ConfigurationsHelper.FeaturedRecordsSizePerPage;
            }

            HttpCookie LangCookie           = Request.Cookies["LangCookie"];
            FeaturedProductsViewModel model = new FeaturedProductsViewModel();

            model.Products = ProductsService.Instance.SearchFeaturedProducts(pageSize, new List <int>()
            {
                productID.HasValue?productID.Value: 0
            });



            if (LangCookie != null)
            {
                if (LangCookie.Value == "ar")
                {
                    foreach (var elem in model.Products.ToList())
                    {
                        elem.Name          = elem.ArName;
                        elem.Description   = elem.ArDescription;
                        elem.Summary       = elem.ArSummary;
                        elem.Category.Name = elem.Category.ArName;
                    }
                }
            }



            if (isForHomePage)
            {
                return(PartialView("_FeaturedProductsHomePage", model));
            }
            else
            {
                return(PartialView("_FeaturedProducts", model));
            }
        }
예제 #17
0
        public ViewResult Index()
        {
            var currencyCode = this.CurrencyProfileService.GetCurrencyCode();
            var currency = this.currencyProvider.GetCurrency(currencyCode);

            var productService =
                new ProductService(this.repository);

            var vm = new FeaturedProductsViewModel();

            var products =
                productService.GetFeaturedProducts(this.User);

            foreach (var product in products)
            {
                var productVM = new ProductViewModel(product.ConvertTo(currency));
                vm.Products.Add(productVM);
            }

            return this.View(vm);
        }
예제 #18
0
        public ViewResult Index()
        {
            var currencyCode = this.CurrencyProfileService.GetCurrencyCode();
            var currency     = this.currencyProvider.GetCurrency(currencyCode);

            var productService =
                new ProductService(this.repository);

            var vm = new FeaturedProductsViewModel();

            var products =
                productService.GetFeaturedProducts(this.User);

            foreach (var product in products)
            {
                var productVM = new ProductViewModel(product.ConvertTo(currency));
                vm.Products.Add(productVM);
            }

            return(this.View(vm));
        }
예제 #19
0
        public override object GetModel(FeaturedProducts widget)
        {
            var model = new FeaturedProductsViewModel {
                Title = widget.Name
            };
            var rawValues = widget.ListOfFeaturedProducts.Split(',');
            var ids       = new List <int>();

            foreach (var items in rawValues.Select(value => value.Split('/')))
            {
                int id;
                if (int.TryParse(items[0], out id) && id != 0)
                {
                    ids.Add(id);
                }
            }
            model.Products.AddRange(_session.QueryOver <Product>()
                                    .Where(arg => arg.Id.IsIn(ids.ToList()))
                                    .Cacheable()
                                    .List()
                                    .OrderBy(arg => ids.IndexOf(arg.Id)).GetCardModels());
            model.Cart = _cart;
            return(model);
        }
 //
 // GET: /ContentBlocks/FeaturedProducts/
 public ActionResult Index(ContentBlock block)
 {
     FeaturedProductsViewModel model = new FeaturedProductsViewModel();
     model.Items = PrepProducts(MTApp.CatalogServices.Products.FindFeatured(1, 100));
     return View(model);
 }