本文整理汇总了C#中SearchModel类的典型用法代码示例。如果您正苦于以下问题:C# SearchModel类的具体用法?C# SearchModel怎么用?C# SearchModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchModel类属于命名空间,在下文中一共展示了SearchModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: List
/* Creates the grid data */
public ActionResult List(SearchParameter searchP, SearchModel searchModel)
{
var model = _stores.AsQueryable();
GridData data = model.ToGridData(searchModel, new[] { "Id", "Name", "Address" });
return Json(data, JsonRequestBehavior.AllowGet);
}
示例2: TestSearchEmpty
public void TestSearchEmpty()
{
SearchModel<Status> model = new SearchModel<Status>();
SearchValidationResult res = model.IsValidSearchCombination();
Assert.False(res.IsValid);
Assert.AreEqual(StringResource.NO_VALUES_TO_SEARCH, res.Description);
}
示例3: TestCombineSearch
public void TestCombineSearch()
{
// create mock of MovieRepository and construct SearchHelper with it
Mock<MovieRepository> repository = new Mock<MovieRepository>();
repository.Setup(x => x.Select<MovieModel>()).Returns(movies.AsQueryable());
SearchHelper searcher = new SearchHelper(repository.Object);
// test cases
//1
SearchModel search1 = new SearchModel
{
MovieName = new SearchOption<string>(),
Genre = new SearchOption<Genre>(),
ActorLastName = new SearchOption<string>(),
};
List<MovieModel> result1 = searcher.Search(search1);
Assert.IsTrue(result1.Count == 3);
Assert.IsTrue(result1.Where(x => x.Name == movies[0].Name).Any());
Assert.IsTrue(result1.Where(x => x.Name == movies[1].Name).Any());
Assert.IsTrue(result1.Where(x => x.Name == movies[2].Name).Any());
//2
SearchModel search2 = new SearchModel
{
MovieName = new SearchOption<string>(),
Genre = new SearchOption<Genre> { Value = Genre.Drammatic, IsCritical = true },
ActorLastName = new SearchOption<string> { Value = "Стоун", IsCritical = true },
};
List<MovieModel> result2 = searcher.Search(search2);
Assert.IsTrue(result2.Count == 1);
Assert.IsTrue(result2.Where(x => x.Name == movies[1].Name).Any());
}
示例4: Search
public ActionResult Search(SearchModel model)
{
ITwitterClient twitterClient = new TwitterClient();
var tweetRepository = new TweetPageRepository();
var cachedPage = tweetRepository.GetPageBySearchString(model.HashtagToSearchFor, model.PageToRetrieve);
if (cachedPage != null)
{
return PartialView(cachedPage.ToModel(model.PageToRetrieve, PAGE_SIZE, model.HashtagToSearchFor));
}
int twitterPage = (int)Math.Ceiling(model.PageToRetrieve / (float)PAGE_SIZE);
var searchResults = twitterClient.SearchByHashtag(model.HashtagToSearchFor, CACHE_SIZE, twitterPage);
int pageCount = (int)Math.Ceiling(searchResults.Count()/(decimal)PAGE_SIZE);
int cachePageRangeStart = ((twitterPage - 1) * PAGE_SIZE) + 1;
var searchResultPages = Enumerable.Range(0, pageCount)
.Select(pageNo => searchResults.Skip(pageNo * PAGE_SIZE).Take(PAGE_SIZE))
.Select((page, pageNo) => page.ToRepositoryContract(cachePageRangeStart + pageNo, PAGE_SIZE, model.HashtagToSearchFor));
tweetRepository.ReplacePages(searchResultPages);
var currentPageResult = searchResultPages.FirstOrDefault(page => page.Page == model.PageToRetrieve);
return PartialView(currentPageResult.ToModel(model.PageToRetrieve, PAGE_SIZE, model.HashtagToSearchFor));
}
示例5: SearchModule
public SearchModule ()
{
Get ["/search"] = parameters => {
SearchModel model = new SearchModel();
model.Planeswalker = ((Planeswalker)this.Context.CurrentUser);
model.ActiveMenu = "search";
return View["Search", model];
};
Post ["/search"] = parameters => {
SearchModel model = this.Bind<SearchModel>();
model.Planeswalker = ((Planeswalker)this.Context.CurrentUser);
UserCard [] walkerCards = null;
try
{
Card[] cards = magicdb.Search(model.Term);
model.ActiveMenu = "search";
cards = cards
.AsEnumerable()
.OrderBy(x => x.Name)
.ThenByDescending(x => x.ReleasedAt).ToArray();
if(model.Planeswalker != null)
{
int [] cardIds = cards.AsEnumerable().Select(c => c.Id).ToArray();
walkerCards = repository.GetUserCards(model.Planeswalker.Id,cardIds);
}
foreach(var c in cards)
{
CardInfo cardInfo = new CardInfo();
if(walkerCards != null && walkerCards.Length > 0)
{
cardInfo.Amount = walkerCards.AsEnumerable()
.Where(info => info.MultiverseId == c.Id)
.Select(info => info.Amount).FirstOrDefault();
}
else
{
cardInfo.Amount = 0;
}
cardInfo.Card = c;
model.Cards.Add(cardInfo);
}
}
catch(Exception e)
{
model.Errors.Add(e.Message);
}
return View["Search", model];
};
}
示例6: ChildList
public ActionResult ChildList(int productId, SearchModel searchModel)
{
StoreRepository rep = new StoreRepository();
List<Store> stores = rep.GetByProductId(productId);
var model = stores.AsQueryable();
return Json(model.ToGridData(searchModel, new[] { "Id", "Name", "Address" }), JsonRequestBehavior.AllowGet);
}
示例7: SetSearch
public void SetSearch(SearchModel searchRouter)
{
base.SetSearch(searchRouter);
this.SearchBytitleCh = searchRouter.SearchBytitleCh;
this.SearchBytitleEng = searchRouter.SearchBytitleEng;
this.SearchByteacherName = searchRouter.SearchByteacherName;
this.SearchBySkill = searchRouter.SearchBySkill;
}
示例8: Search
public static IQueryable<RentCrib> Search(SearchModel queryParams)
{
Stack<Expression<Func<RentCrib, bool>>> filters = BuildFilters(queryParams);
IQueryable<RentCrib> list = Db.RentCribs.Where(x => x.Active).OrderBy(x => x.DatePost);
var filtered = ApplyFilters(list, filters);
return filtered;
}
示例9: List
public ActionResult List(SearchModel searchModel)
{
ProductRepository repository = new ProductRepository();
List<Product> products = repository.ListAll();
return Json(products.AsQueryable().ToGridData(searchModel, new[] { "Id", "Name", "CompanyName", "Price" }), JsonRequestBehavior.AllowGet);
}
示例10: List
/* Notice the List methid accepts an additional
* SearchParameter parameter - this is achieved using the -
* Html.BuildQuery method used in the view Grid declaration */
public ActionResult List(SearchParameter searchP, SearchModel searchModel)
{
StoreRepository repository = new StoreRepository();
List<Store> stores = repository.ListAll();
var model = stores.AsQueryable();
return Json(model.ToGridData(searchModel, new[] { "Id", "Name", "Address" }), JsonRequestBehavior.AllowGet);
}
示例11: Search
public ActionResult Search(string name, string comm, string addr)
{
if (!Authenticate(checkOrgLeadersOnly: true))
return Content("not authorized");
Response.NoCache();
var m = new SearchModel(name, comm, addr);
return new SearchResult0(m.PeopleList(), m.Count());
}
示例12: ListNodes
/// <summary>
/// grid显示函数
/// </summary>
/// <param name="searchModel">grid搜索模型</param>
/// <returns>程序功能节点</returns>
public ActionResult ListNodes(SearchModel searchModel)
{
IQueryable<GeneralProgNode> oPrograms = dbEntity.GeneralProgNodes.Include("Name").Where(p => p.Deleted == false && p.ProgID == progNodeGidGrid).AsQueryable();
GridColumnModelList<GeneralProgNode> columns = new GridColumnModelList<GeneralProgNode>();
columns.Add(p => p.Gid).SetAsPrimaryKey();
columns.Add(p => p.Code);
columns.Add(p => p.Name.GetResource(CurrentSession.Culture)).SetName("Name.Matter");
columns.Add(p => (p.Optional == null) ? "": p.Optional.GetResource(CurrentSession.Culture)).SetName("Optional.Matter");
GridData gridData = oPrograms.ToGridData(searchModel, columns);
return Json(gridData, JsonRequestBehavior.AllowGet);
}
示例13: Index
public ActionResult Index(FormCollection form )
{
var model = new SearchModel { City = form["City"], Zip = form["Zip"], };
if (ModelState.IsValid)
{
return RedirectToAction("Index", "Results");
}
ModelState.AddModelError(string.Empty, "Oops, " + string.Join(" ; ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)));
return View(model);
}
示例14: ListPersons
/* Creates the grid data */
public ActionResult ListPersons(SearchModel searchModel)
{
List<Person> stores = _persons;
IQueryable<Person> model =
(from Person p in stores
select p).AsQueryable();
GridData gridData = model.ToGridData(searchModel, Columns.PersonColumns);
return Json(gridData, JsonRequestBehavior.AllowGet);
}
示例15: SearchResults
public ActionResult SearchResults(string name, string comm, string addr)
{
if (!Authenticate(checkOrgLeadersOnly: true))
return Content("not authorized");
if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Access"))
return Content("not authorized");
Response.NoCache();
DbUtil.LogActivity($"iphone search '{name}'");
var m = new SearchModel(name, comm, addr);
return new SearchResult(m.PeopleList(), m.Count());
}