public BrowseModel(MiniSearchModel searchModel, PaginatedList <Mini> minis) { SearchModel = searchModel; Minis = minis ?? PaginatedList.Empty <Mini>(); Random rand = new Random(); ShowRateResults = (rand.Next(0, 24) == 0); }
public async Task <IActionResult> BrowseMinis( [FromQuery] MiniSearchModel search = null, [FromQuery] int pageSize = 21, [FromQuery] int pageIndex = 1) { //Mild hack - There's some case where pageIndex is hitting 0 and I can't tell how/why. (GitHub #182) if (pageIndex == 0) { pageIndex = 1; } //I really don't want people manually setting massive page sizes, so hardcoding this for now. pageSize = 21; PageInfo pagingInfo = new PageInfo(pageSize, pageIndex); MiniSearchRequest searchRequest = new MiniSearchRequest { PageInfo = pagingInfo }; _mapper.Map(search).Over(searchRequest); PaginatedList <Mini> searchResult = await _mediator.Send(searchRequest); BrowseModel model = new BrowseModel(search, searchResult); _telemetry.TrackEvent("NewMiniSearch", new Dictionary <string, string> { { "SearchString", searchRequest.SearchString }, { "Tags", String.Join(",", searchRequest.Tags) }, { "FreeOnly", searchRequest.FreeOnly.ToString() }, { "HadResults", searchResult.Count > 0 ? "True" : "False" }, { "PageIndex", searchRequest.PageInfo.PageIndex.ToString() }, { "SortType", searchRequest.SortType } }); return(View("BrowseMinis", model)); }