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 Checkout()
        {
            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var model = new IndexViewModel()
            {
                Products = itemsInSession
            };

            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);
        }
        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)
        {
            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);
        }
        public ActionResult Checkout()
        {
            ViewBag.Message = Environment.MachineName;
            string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            int start = connectionString.IndexOf(";Password="******";", start + 1);
            var connectionStringSafe = connectionString.Remove(start, end - start);
            ViewBag.ConnectionString = connectionStringSafe;

            var itemsInSession = this.Session["Cart"] as List<string> ?? new List<string>();
            var model = new IndexViewModel()
            {
                Products = itemsInSession
            };

            return View(model);
        }