public IQueryable <ReceiptBatch> GetBySearch(SearchPager searchPager) { return(All() .OfType <ReceiptBatch>() .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }
public IQueryable <Fund> GetBySearch(SearchPager searchPager) { return(context.Funds .Where(FilterByOrganization()) .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }
public async Task <ActionResult> Index(SearchPager searchPager) { Logger.Trace("Index::{0}", searchPager); var query = new LivingUnitSearchQuery(pager: searchPager); var result = await mediator.SendAsync(query); Logger.Info("{0} matches found".FormatWith(result.Items.TotalItemCount)); return(View(result)); }
public async Task <ActionResult> Index(SearchPager searchPager) { Logger.Trace("Index"); var query = new FundSearchQuery(pager: searchPager); var result = await mediator.SendAsync(query); Logger.Info("", result.Items.TotalItemCount); return(View(result)); }
public async Task <ActionResult> Show(int?id, SearchPager searchPager) { Logger.Trace("Index::{0}", id); var query = new FundDetailsQuery(fundId: id.Value, searchPager: searchPager); var result = await mediator.SendAsync(query); if (result == null) { return(new HttpNotFoundResult("A Fund with id {0} was not found".FormatWith(id))); } return(View(result)); }
public IQueryable <Transaction> GetBySearch(SearchPager searchPager) { var pager = searchPager as TransactionsSearchPager; if (pager == null) { return(All() .Where(FilterBySearch(searchPager.Search))); } return(All() .Where(FilterBySearch(pager.Search)) .Where(FilterByDates(pager.FromDate, pager.ToDate))); }
public async Task Can_search_clients_with_no_results() { var pager = new SearchPager { Search = "s" }; var query = new ClientSearchQuery(pager); clients.GetBySearch(Arg.Is(pager)).Returns(Enumerable.Empty <Client>().AsAsyncQueryable()); var result = await handlerHandler.Handle(query); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ClientSearchResult)); Assert.IsFalse(result.Items.Any()); }
public IQueryable <Payee> GetBySearch(SearchPager searchPager) { var pager = searchPager as PayeesSearchPager; if (pager != null) { return(All() .Where(FilterByIsActive(pager.IsActive)) .Where(FilterByType(pager.Type)) .Where(FilterBySearch(pager.Search))); } return(All() .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }
public void To_string_format() { var item = new SearchPager { Page = 2, PageSize = 5, IsActive = false, Search = "foo" }; var result = item.ToString(); Assert.IsTrue(result.Contains(item.Page.ToString())); Assert.IsTrue(result.Contains(item.PageSize.ToString())); Assert.IsTrue(result.Contains(item.IsActive.ToString())); Assert.IsTrue(result.Contains(item.Search)); }
public async Task Get_Index_with_default_pager() { var pager = new SearchPager(); var viewModel = new ClientSearchResult { Items = new PagedList <Client>(Enumerable.Empty <Client>(), 1, 10) }; mediator.SendAsync(Arg.Any <ClientSearchQuery>()) .Returns(Task.FromResult(viewModel)); var result = await controller.Index(pager) as ViewResult; Assert.AreEqual(result.Model, viewModel); mediator.Received() .SendAsync(Arg.Is <ClientSearchQuery>(q => q.Pager == pager)) .IgnoreAwaitForNSubstituteAssertion(); }
public async Task Can_search_clients_with_results() { var id = 42; var client = new Client { Id = id, LastName = "foo", FirstName = "bar", Identifiers = Enumerable.Empty <ClientIdentifier>().ToList() }; var pager = new SearchPager { Search = "s" }; var query = new ClientSearchQuery(pager); clients.GetBySearch(Arg.Is(pager)).Returns(new[] { client }.AsAsyncQueryable()); var result = await handlerHandler.Handle(query); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(ClientSearchResult)); Assert.IsTrue(result.Items.Contains(client)); }
public async Task Handle(QueryDashboard command, DashboardResult response) { Logger.Trace("Handle"); if (response == null) { return; } var search = new SearchPager { IsActive = true, PageSize = 5, Page = 1 }; var widget = new BatchesWidget { Batches = await batches.GetBySearch(search) .Take(search.PageSize) .ToArrayAsync(), Funds = await funds.All() .ToArrayAsync() }; response.Widgets.Add(widget); }
public FundDetailsQuery(int fundId, SearchPager searchPager) { this.FundId = fundId; this.Pager = searchPager; }
public IQueryable <Account> GetBySearch(SearchPager searchPager) { return(All() .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }
public IQueryable <SubsidiaryAccount> GetBySearch(SearchPager searchPager) { return(accounts.GetBySearch(searchPager).OfType <SubsidiaryAccount>()); }
public IQueryable <ExpenseCategory> GetBySearch(SearchPager searchPager) { return(All() .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }
public ReceiptSourceSearchQuery(SearchPager pager) { this.Pager = pager; }
public IQueryable <TransferBatch> GetBySearch(SearchPager searchPager) { throw new NotImplementedException(); }
protected void Page_Load(object sender, EventArgs e) { string apiUrl = ConfigurationManager.AppSettings["Earth911.ApiUrl"]; string apiKey = ConfigurationManager.AppSettings["Earth911.ApiKey"]; Earth911.Api api = new Earth911.Api(apiUrl, apiKey); searchArgs = new SearchArgs(Request, api); baseUrl = "Search.aspx?" + searchArgs.QueryString; JsonArray locations = new JsonArray(); JsonArray programs = new JsonArray(); JsonObject args; // Perform search queies if (searchArgs.What != "" && searchArgs.FoundWhere) { // Find matching materials args = new JsonObject(); args["query"] = searchArgs.What; JsonArray materials = (JsonArray)api.Call("earth911.searchMaterials", args); JsonArray materialIds = new JsonArray(); foreach (JsonObject material in materials) { materialIds.Add((JsonNumber)material["material_id"]); } // If materials were found, run the query if (materialIds.Count > 0) { args = new JsonObject(); args["latitude"] = searchArgs.Latitude; args["longitude"] = searchArgs.Longitude; args["material_id"] = materialIds; locations = (JsonArray)api.Call("earth911.searchLocations", args); programs = (JsonArray)api.Call("earth911.searchPrograms", args); } } // Combine locations and programs, sort by distance results = new List <JsonObject>(); foreach (JsonObject location in locations) { // Filtering of undesirable locations can be done here, // prior to pagination. // // if (location["description"].ToString() == "Company X") // { // continue; // } location["type"] = "location"; location["id"] = location["location_id"]; results.Add(location); } foreach (JsonObject program in programs) { program["type"] = "program"; program["id"] = program["program_id"]; results.Add(program); } results.Sort(new DistanceComparer()); // Paginate results int page = Convert.ToInt32(Request.QueryString["page"]); searchPager = new SearchPager <JsonObject>(results, page); results = searchPager.Result(); // Load details for this page of results JsonArray locationIds = new JsonArray(); JsonArray programIds = new JsonArray(); foreach (JsonObject result in results) { if (result["type"] == "location") { locationIds.Add(result["id"]); } if (result["type"] == "program") { programIds.Add(result["id"]); } result["url"] = "Details.aspx?type=" + result["type"] + "&id=" + result["id"] + "&" + searchArgs.QueryString; } locationDetails = new JsonObject(); if (locationIds.Count > 0) { args = new JsonObject(); args["location_id"] = locationIds; locationDetails = (JsonObject)api.Call("earth911.getLocationDetails", args); } programDetails = new JsonObject(); if (programIds.Count > 0) { args = new JsonObject(); args["program_id"] = programIds; programDetails = (JsonObject)api.Call("earth911.getProgramDetails", args); } }
public IQueryable <Organization> GetBySearch(SearchPager searchPager) { throw new NotImplementedException(); }
public IQueryable <Order> GetBySearch(SearchPager searchPager) { return(All() .Where(FilterBySearch(searchPager.Search))); }
protected void Page_Load(object sender, EventArgs e) { string apiUrl = ConfigurationManager.AppSettings["Earth911.ApiUrl"]; string apiKey = ConfigurationManager.AppSettings["Earth911.ApiKey"]; Earth911.Api api = new Earth911.Api(apiUrl, apiKey); searchArgs = new SearchArgs(Request, api); baseUrl = "Search.aspx?" + searchArgs.QueryString; JsonArray locations = new JsonArray(); JsonArray programs = new JsonArray(); JsonObject args; // Perform search queies if (searchArgs.What != "" && searchArgs.FoundWhere) { // Find matching materials args = new JsonObject(); args["query"] = searchArgs.What; JsonArray materials = (JsonArray)api.Call("earth911.searchMaterials", args); JsonArray materialIds = new JsonArray(); foreach (JsonObject material in materials) { materialIds.Add((JsonNumber)material["material_id"]); } // If materials were found, run the query if (materialIds.Count > 0) { args = new JsonObject(); args["latitude"] = searchArgs.Latitude; args["longitude"] = searchArgs.Longitude; args["material_id"] = materialIds; locations = (JsonArray)api.Call("earth911.searchLocations", args); programs = (JsonArray)api.Call("earth911.searchPrograms", args); } } // Combine locations and programs, sort by distance results = new List<JsonObject>(); foreach (JsonObject location in locations) { // Filtering of undesirable locations can be done here, // prior to pagination. // // if (location["description"].ToString() == "Company X") // { // continue; // } location["type"] = "location"; location["id"] = location["location_id"]; results.Add(location); } foreach (JsonObject program in programs) { program["type"] = "program"; program["id"] = program["program_id"]; results.Add(program); } results.Sort(new DistanceComparer()); // Paginate results int page = Convert.ToInt32(Request.QueryString["page"]); searchPager = new SearchPager<JsonObject>(results, page); results = searchPager.Result(); // Load details for this page of results JsonArray locationIds = new JsonArray(); JsonArray programIds = new JsonArray(); foreach (JsonObject result in results) { if (result["type"] == "location") { locationIds.Add(result["id"]); } if (result["type"] == "program") { programIds.Add(result["id"]); } result["url"] = "Details.aspx?type=" + result["type"] + "&id=" + result["id"] + "&" + searchArgs.QueryString; } locationDetails = new JsonObject(); if (locationIds.Count > 0) { args = new JsonObject(); args["location_id"] = locationIds; locationDetails = (JsonObject)api.Call("earth911.getLocationDetails", args); } programDetails = new JsonObject(); if (programIds.Count > 0) { args = new JsonObject(); args["program_id"] = programIds; programDetails = (JsonObject)api.Call("earth911.getProgramDetails", args); } }
public IActionResult Index(string SearchText = "", int page = 1, int pageSize = 30) { _logger.LogInformation($"Total Products available {_dbContext.Products.Count()}"); List <Product> products; if (SearchText != "" && SearchText != null) { _dbContext.ChangeTracker.AutoDetectChangesEnabled = false; var stopWatch = Stopwatch.StartNew(); products = _dbContext.Products .Where(p => p.Name.Contains(SearchText)) .Include(u => u.ApplicationUser) .OrderByDescending(p => p.CreatedAt) .ToList(); stopWatch.Stop(); _logger.LogInformation($"Search and Fetch specific records in Records in, ${stopWatch.Elapsed}"); //_dbContext.ChangeTracker.AutoDetectChangesEnabled = true; } else { //_dbContext.ChangeTracker.AutoDetectChangesEnabled = false; var stopWatchList = Stopwatch.StartNew(); products = _dbContext.Products .Include(u => u.ApplicationUser) .OrderByDescending(p => p.CreatedAt) .Take(1000) .ToList(); stopWatchList.Stop(); _logger.LogInformation($"1- Fethcing All Records using (Include) in, {stopWatchList.Elapsed}"); //_dbContext.ChangeTracker.AutoDetectChangesEnabled = true; // Eager Loading using 'SELECT', // don’t need an 'Include' call anymore since Entity Framework “understands” from the Select call that we need a field /* * var stopWatchVar = Stopwatch.StartNew(); * var varProducts = _dbContext.Products * .OrderByDescending(p => p.CreatedAt) * .Select(p => new { p.Id, p.Name, p.Description, p.Price, p.ApplicationUser.UserName }) * .ToList(); * * stopWatchVar.Stop(); *_logger.LogInformation($"2- Fethcing All Records using (Select) in, {stopWatchVar.Elapsed}"); */ } //int pageSize = 30; if (page < 1) { page = 1; } int countRecords = products.Count; int skipRecords = (page - 1) * pageSize; var modelList = products.Skip(skipRecords).Take(pageSize); SearchPager searchPager = new SearchPager(countRecords, page, pageSize) { Action = "Index", Controller = "Home", SearchText = SearchText }; ViewBag.SearchPager = searchPager; ViewBag.PageSizes = GetPageSizes(pageSize); //_logger.LogInformation($"pageSize: {pageSize}"); return(View(modelList)); }
public ExpenseCategorySearchQuery(SearchPager pager) { this.Pager = pager; }
public FundSearchQuery(SearchPager pager) { this.Pager = pager; }
public LivingUnitSearchQuery(SearchPager pager) { this.Pager = pager; }
public IQueryable <Receipt> GetBySearch(SearchPager searchPager) { return(transactions.GetBySearch(searchPager) .OfType <Receipt>() .Where(FilterBySearch(searchPager.Search))); }
public ClientSearchQuery(SearchPager pager) { this.Pager = pager; }
public IQueryable <TransactionBatch> GetBySearch(SearchPager searchPager) { return(All() .Where(FilterByIsActive(searchPager.IsActive)) .Where(FilterBySearch(searchPager.Search))); }