Example #1
0
        public ActionResult GetRecordAjax(string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                return(null);
            }

            var res = _IRepository.GetRecord(id);

            addImageMetaData(ref res);
            var results_vm = new SearchAjaxViewModel(res)
            {
                Rows = 1, RowStart = 0
            };

            return(Json(results_vm, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        //[HttpPost]
        public ActionResult SearchAjax(string user_id, string term, string collection_ids, int rows, int row_start, string parent_id, string sort_orders, string facet_constraints, string lang_id) // SearchFacetViewModel facet)
        {
            var sq = new SearchQuery(user_id, term, collection_ids, rows, row_start, parent_id, sort_orders, facet_constraints);

            if (String.IsNullOrEmpty(user_id))
            {
                user_id = Guid.Empty.ToString();
            }

            //XmlDataHelper.SearchXml(Request.GetBaseUri(Url), term, new List<string>(ids), collection_search)
            var res = _IRepository.Search(sq, Facets, FacetRanges);

            addImageMetaData(ref res);

            // save all searches, even if user not logged in (for complete stats). if start row == 0 assume new search (and not a seach page nav click)
            var kvp = new KeyValuePair <Guid, String>(Guid.Empty, null);

            if (row_start == 0)
            {
                kvp = _IUserSearchRepository.SearchSave(ApplicationIdInquire, lang_id, user_id, sq, res.NumFound);
            }

            res.SearchID = kvp.Key; // if search was saved this will NOT be Guid.Empty, so then add it to users list as a newly saved search
            sq.SearchID  = kvp.Key;

            res.SearchDisplayName = kvp.Value;
            sq.DisplayName        = kvp.Value;

            sq.NumFound     = res.NumFound;
            res.SearchQuery = sq;

            var results_vm = new SearchAjaxViewModel(res)
            {
                Rows = rows, RowStart = row_start
            };

            return(Json(results_vm, JsonRequestBehavior.AllowGet));
        }