// // GET: /Admin/ public ActionResult Index() { //instance search history model SearchHistoryModel searchHistoryModel = new SearchHistoryModel(); AdminIndexViewModel adminIndexViewModel = new AdminIndexViewModel(); adminIndexViewModel.SearchHistoriesTopXLastest = searchHistoryModel.GetTopLastest(5); return(View(adminIndexViewModel)); }
private async void BtnMap_OnClicked(object sender, EventArgs e) { Button btn = sender as Button; //TODO: more efficient way of retrieving coordinates. var allItems = await AzureData.AzureDataInstance.GetSearchHistory(); SearchHistoryModel selectedItem = allItems.SingleOrDefault(s => s.Id == btn.CommandParameter.ToString()); //TODO: Add iOS & WinMobile platform URI's Device.OpenUri(new Uri($"geo:0,0?q={selectedItem.Latitude} {selectedItem.Longitude}")); }
public IActionResult Create(SearchHistoryModel model) { var result = _searchHistoryService.Create(model.DepartureId, model.ArrivalId, model.DepartureDate, model.ArrivalDate, model.BookingType, model.Passengers); if (result.IsSuccessfull == true) { return(Ok()); } else { return(BadRequest()); } }
void storeSearchHistory(SearchCriteria search) { var model = new SearchHistoryModel() { Search = search.SearchText, User = search.Meta.User, Meta = new SearchHistoryModelMeta() { Criteria = search } }; BackgroundJob.Enqueue <ISearchPostgres>(db => db.AddSearchAsync(model)); }
/// <summary> /// 搜索 /// </summary> public void ClickSearchExecute() { SearchHistoryIsOpen = false; var shm = new SearchHistoryModel(SearchContent); new SearchHistoryManager().Insert(shm); //如果搜索历史列表项大于等于10个,移出最后一个 if (SearchHistoryList.Count >= 10) { SearchHistoryList.RemoveAt(9); } SearchHistoryList.Insert(0, shm); CurrentPage = PageManager.SearchPage; (PageManager.SearchPage.DataContext as SearchPageViewModel).SearchContent = SearchContent; }
public IActionResult GetSearchHistoryById(int Sid) { var s = _repository.GetSearchHistoryById(Sid); if (s != null) { var model = new SearchHistoryModel(); model.SearchHistoryUrl = Url.Link(nameof(GetSearchHistoryById), new { Sid = s.Id }); model.SearchText = s.SearchContent; model.SearchDate = s.SearchDate; model.RemoveHistory = Url.Link(nameof(DeleteSearchHistory), new { Sid = s.Id }); return(Ok(model)); } return(NotFound()); }
public async Task AddSearchAsync(SearchHistoryModel history) { await db.TransactionAsync(transaction => { var cmdParameters = "@search, @meta, @username"; var cmd = new NpgsqlCommand(); cmd.Transaction = transaction; cmd.Connection = transaction.Connection; cmd.CommandText = $@"INSERT INTO {searchHistoryTable} ({searchHistoryInsertColumns}) VALUES ({cmdParameters});"; cmd.Parameters.AddWithValue("@search", history.Search); cmd.Parameters.AddWithValue("@meta", NpgsqlTypes.NpgsqlDbType.Jsonb, (history.Meta == null) ? "" : JsonConvert.SerializeObject(history.Meta)); cmd.Parameters.AddWithValue("@username", history.User); cmd.ExecuteNonQuery(); }); }
public async Task SubmitSearchHistory(SearchHistoryModel searchHistory) { await searchHistoryTable.InsertAsync(searchHistory); }
// // GET: /Result/ public ActionResult Index(string keyword) { // If keyword is null or empty then system will redirect to home page if (keyword == null || keyword.Trim().Equals("")) { return(RedirectToAction("Index", "Home")); } // Instance model layer ResultModel resultModel = new ResultModel(); // Instance view model for result ResultViewModel resultViewModel = new ResultViewModel(); // Get entry by keyword WordIndex entry = resultModel.GetEntryByKeyword(keyword); // Property of search history bool isExistData = true; // Check has entry if (entry != null) { //set view model resultViewModel.Entry = entry; // List result if (entry.Synsets.Where(x => x.Category == "n").Count() > 0) { ViewBag.Noun = entry.Synsets.Where(x => x.Category == "n"); } if (entry.Synsets.Where(x => x.Category == "v").Count() > 0) { ViewBag.Verb = entry.Synsets.Where(x => x.Category == "v"); } //add history isExistData = true; } else { isExistData = false; } //add history SearchHistoryModel searchHistoryModel = new SearchHistoryModel(); searchHistoryModel.AddSearchHistory(keyword, isExistData); //add user history if (Request.IsAuthenticated) { UserHistoryModel userHistoryModel = new UserHistoryModel(); userHistoryModel.AddUserHistory(keyword); } //--------------------------------------- // Store 5 recent keywords if (Session["Recent"] == null) { Session["Recent"] = new List <string>(); } int countRecent = ((List <string>)Session["Recent"]).Count; if (((List <string>)Session["Recent"]).Contains(keyword)) { ((List <string>)Session["Recent"]).Remove(keyword); } else if (countRecent >= 5) { ((List <string>)Session["Recent"]).RemoveAt(0); } ((List <string>)Session["Recent"]).Add(keyword); //((List<string>)Session["Recent"]).Reverse(); //string[] arraySuggest = new string[((List<string>)Session["Recent"]).Count]; //((List<string>)Session["Recent"]).CopyTo(arraySuggest); //ViewBag.Recent = arraySuggest; //((List<string>)Session["Recent"]).Reverse(); //--------------------------------------- //ViewBag.Title ViewBag.Title = "Kết quả tra cứu cho '" + keyword + "'"; // add suggest terms EntriesModel entryModel = new EntriesModel(); resultViewModel.SuggestTerm = entryModel.SuggestTerm(keyword); // get questions QAModel qaModel = new QAModel(); resultViewModel.Questions = qaModel.GetQuestionPaged(1, 10); return(View(resultViewModel)); }