public ActionResult Index(ProductSearchCriteria criteria)
        {
            var sqlQuery = new SqlSearchProductQuery(criteria);

            var watch  = System.Diagnostics.Stopwatch.StartNew();
            var result = sqlQuery.Execute();

            watch.Stop();
            var sqlElapsedMs = watch.ElapsedMilliseconds;

            var redisQuery = new SearchProductQuery(criteria);

            watch  = System.Diagnostics.Stopwatch.StartNew();
            result = redisQuery.Execute();
            watch.Stop();
            var redisElapsedMs = watch.ElapsedMilliseconds;

            var viewModel = new SearchResultViewModel <ProductModel>();

            viewModel.Data           = result;
            viewModel.SqlQueryTime   = sqlElapsedMs;
            viewModel.RedisQueryTime = redisElapsedMs;
            ViewBag.Heading          = "Compare View";
            return(View(viewModel));
        }
        public ActionResult SqlSearch(ProductSearchCriteria criteria)
        {
            var watch  = System.Diagnostics.Stopwatch.StartNew();
            var query  = new SqlSearchProductQuery(criteria);
            var result = query.Execute();

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            var viewModel = new SearchResultViewModel <ProductModel>();

            viewModel.Data      = result;
            viewModel.QueryTime = elapsedMs;
            return(PartialView("~/Views/Products/_Search.cshtml", viewModel));
        }
        public ActionResult SqlIndex(ProductSearchCriteria criteria)
        {
            var watch  = System.Diagnostics.Stopwatch.StartNew();
            var query  = new SqlSearchProductQuery(criteria);
            var result = query.Execute();

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            var viewModel = new SearchResultViewModel <ProductModel>();

            viewModel.Data      = result;
            viewModel.QueryTime = elapsedMs;
            ViewBag.Heading     = "Query with SQL";
            ViewBag.IsSql       = true;
            return(View("~/Views/Products/Index.cshtml", viewModel));
        }