public ActionResult Search(string SearchCriteria)
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = string.IsNullOrEmpty(SearchCriteria) ?
                productRepository.GetProducts() : productRepository.Search(SearchCriteria);

            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            string elapsedTime = String.Format("{0:00}.{1:000} sec", ts.Seconds, ts.Milliseconds);


            // add all products currently not in session
            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            var model = new IndexViewModel()
            {
                Products = filteredProducts,
                SearchCriteria = SearchCriteria
            };
            Diagnostic();
            ViewBag.RepoTime = elapsedTime;
            return View("Index", model);
        }
Esempio n. 2
0
        public ActionResult Search(string SearchCriteria)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = string.IsNullOrEmpty(SearchCriteria) ?
                           productRepository.GetProducts() : productRepository.Search(SearchCriteria);

            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            string elapsedTime = String.Format("{0:00}.{1:000} sec", ts.Seconds, ts.Milliseconds);


            // add all products currently not in session
            var itemsInSession   = this.Session["Cart"] as List <string> ?? new List <string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            var model = new IndexViewModel()
            {
                Products       = filteredProducts,
                SearchCriteria = SearchCriteria
            };

            Diagnostic();
            ViewBag.RepoTime = elapsedTime;
            return(View("Index", model));
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            bool enableCache      = (bool)this.Session["EnableCache"];
            bool enableLocalCache = (bool)this.Session["EnableLocalCache"];

            // retrieve product catalog from repository and measure the elapsed time
            Services.IProductRepository productRepository = new Services.ProductsRepository(enableCache, enableLocalCache);
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            var products = productRepository.GetProducts();

            stopWatch.Stop();

            // add all products currently not in session
            var itemsInSession   = this.Session["Cart"] as List <string> ?? new List <string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            IndexViewModel model = new IndexViewModel()
            {
                Products            = filteredProducts,
                ElapsedTime         = stopWatch.ElapsedMilliseconds,
                IsCacheEnabled      = enableCache,
                IsLocalCacheEnabled = enableLocalCache,
                ObjectId            = products.GetHashCode().ToString()
            };

            return(this.View(model));
        }
        public ActionResult Index()
        {
            bool enableCache = (bool)this.Session["EnableCache"];

            // retrieve product catalog from repository and measure the elapsed time
            Services.IProductRepository productRepository = new Services.ProductsRepository();
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            var products = productRepository.GetProducts();
            stopWatch.Stop();

            // add all products currently not in session
            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            IndexViewModel model = new IndexViewModel()
            {
                Products = filteredProducts,
                ElapsedTime = stopWatch.ElapsedMilliseconds,
                IsCacheEnabled = enableCache,
                ObjectId = products.GetHashCode().ToString()
            };

            return View(model);
        }
        public ActionResult Index()
        {
            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = productRepository.GetProducts();

            // add all products currently not in session
            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            IndexViewModel model = new IndexViewModel()
            {
                Products = filteredProducts
            };

            return View(model);
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = productRepository.GetProducts();

            // add all products currently not in session
            var itemsInSession   = this.Session["Cart"] as List <string> ?? new List <string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            IndexViewModel model = new IndexViewModel()
            {
                Products = filteredProducts
            };

            return(this.View(model));
        }
Esempio n. 7
0
        public ActionResult Search(string SearchCriteria)
        {
            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = string.IsNullOrEmpty(SearchCriteria) ?
                           productRepository.GetProducts() : productRepository.Search(SearchCriteria);

            // add all products currently not in session
            var itemsInSession   = this.Session["Cart"] as List <string> ?? new List <string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            var model = new IndexViewModel()
            {
                Products       = filteredProducts,
                SearchCriteria = SearchCriteria
            };

            return(View("Index", model));
        }
        public ActionResult Search(string SearchCriteria)
        {
            Services.IProductRepository productRepository = new Services.ProductsRepository();
            var products = string.IsNullOrEmpty(SearchCriteria) ?
                productRepository.GetProducts() : productRepository.Search(SearchCriteria);

            // add all products currently not in session
            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var filteredProducts = products.Where(item => !itemsInSession.Contains(item));

            var model = new IndexViewModel()
            {
                Products = filteredProducts,
                SearchCriteria = SearchCriteria
            };

            return View("Index", model);
        }