Example #1
0
        public virtual ActionResult Search(SearchQuery query, string sort, string sortdir)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            if (sort != null && sortdir != null)
            {
                switch (sort.ToString().ToLower())
                {
                    case "title":
                        query.SortOrder = (sortdir.ToString() == "ASC" ? SortOrder.TitleAsc : SortOrder.TitleDesc);
                        break;
                }
            }

            SearchResults result = _searchService.DoSearch(query);

            ViewBag.Sort = sort;
            ViewBag.SortDir = sortdir;

            ViewData.Model = new SearchViewModel
                                 {
                                     Query = query,
                                     Results = result.List
                                 };

            return View(MVC.Home.Views.Index);
        }
Example #2
0
        public SearchResults DoSearch(SearchQuery query)
        {
            var client = new RestClient();
            client.BaseUrl = _url;

            var request = new RestRequest();
            request.Resource = "Search/General.xml";

            if (query.Category != null)
                request.AddParameter("category", query.Category);
            if (query.SearchString != null)
                request.AddParameter("search_string", query.SearchString);
            if (query.SortOrder != null)
                request.AddParameter("sort_order", query.SortOrder.ToString());
            if (query.BuyNow != null)
                request.AddParameter("buy", query.BuyNow);
            if (query.PayNow != null)
                request.AddParameter("pay", query.PayNow);
            if (query.Page != null)
                request.AddParameter("page", query.Page);
            if (query.Rows != null)
                request.AddParameter("rows", query.Rows);
            if (query.Expired != null)
                request.AddParameter("expired", query.Expired);

            RestResponse<SearchResults> response = client.Execute<SearchResults>(request);

            //Should do some error checking here for invalid responses

            return response.Data;
        }
Example #3
0
        public virtual ActionResult Index(SearchQuery query)
        {
            ViewBag.Sort = null;
            ViewBag.SortDir = null;

            ViewData.Model = new SearchViewModel
                                 {
                                     Query = new SearchQuery {SearchString = "", Expired = false},
                                     Results = new List<Listing>()
                                 };
            return View();
        }
Example #4
0
 public SearchResults DoSearch(SearchQuery query)
 {
     return _dataRepo.DoSearch(query);
 }