Ejemplo n.º 1
0
        public ActionResult Index(SearchFormViewModel form)
        {
            var searchParameters = this.searchParameterMapper.MapFrom(form);

            var searchResult = this.searchTasks.Search(searchParameters);

            var searchPageViewModel = this.blogSearchPageViewModelMapper.MapFrom(searchResult, searchParameters.ContentType, form);

            return this.View(searchPageViewModel);
        }
        /// <summary>
        /// The map from.
        /// </summary>
        /// <param name="searchResults">
        /// The input.
        /// </param>
        /// <param name="searchContentType">
        /// The search Content Type.
        /// </param>
        /// <param name="searchForm">
        /// The search Form.
        /// </param>
        /// <returns>
        /// The blog search page view model.
        /// </returns>
        public SearchPageViewModel MapFrom(
            IEnumerable<AddressableContentBase> searchResults, 
            SearchContentType searchContentType, 
            SearchFormViewModel searchForm)
        {
            var pageViewModel = new SearchPageViewModel
                {
                    Results = searchResults.ToList().MapAllUsing(this.searchResultViewModelMapper), 
                    ContentTypes = this.searchContentTypeSelectListMapper.MapFrom(searchContentType), 
                    Form = searchForm
                };

            if (searchForm.DateFrom.HasValue)
            {
                pageViewModel.DateFrom = searchForm.DateFrom.Value.ToString("dd MMMM yyyy");
            }

            if (searchForm.DateTo.HasValue)
            {
                pageViewModel.DateTo = searchForm.DateTo.Value.ToString("dd MMMM yyyy");
            }

            return pageViewModel;
        }