Example #1
0
        public ActionResult Index(SearchIndexViewModel viewModel)
        {
            if (viewModel == null)
            {
                viewModel = new SearchIndexViewModel();
            }

            var filter = viewModel.Filter;

            filter = !string.IsNullOrEmpty(filter) ? filter.Trim() : string.Empty;

            if (viewModel.AllowRedirect && !string.IsNullOrEmpty(filter))
            {
                var redirectResult = TryRedirect(filter, viewModel.SearchType);

                if (redirectResult != null)
                {
                    return(redirectResult);
                }
            }

            if (!string.IsNullOrEmpty(viewModel.Tag))
            {
                viewModel.TagId = new[] { tagQueries.GetTagIdByName(viewModel.Tag) };
            }

            viewModel.Filter = filter;

            SetSearchEntryType(viewModel.SearchType);

            return(View("Index", viewModel));
        }