public QueryResult <County> Query(QueryStandard query) { var result = new QueryResult <County>(); using (var ctx = GetVtsContext("CountyRepository")) { var qryResult = ctx.Counties.AsQueryable().AsNoTracking(); qryResult = query.IncludeDeactivated ? qryResult.Where(n => n.Status != EntityStatus.Deleted) : qryResult.Where(n => n.Status != EntityStatus.Deleted && n.Status != EntityStatus.Inactive); if (!string.IsNullOrEmpty(query.Description)) { string search = query.Description.ToLower(); qryResult = qryResult.Where( n => n.Name.ToLower().Contains(search)); } var r = qryResult.OrderBy(n => n.Name).ToList(); result.Count = r.Count(); if (query.Skip.HasValue && query.Take.HasValue) { r = r.Skip(query.Skip.Value).Take(query.Take.Value).ToList(); } result.Data = r; } return(result); }
public QueryResult <RegionViewModel> Query(QueryStandard query) { var queryResult = _regionRepository.Query(query); var results = new QueryResult <RegionViewModel>(); results.Count = queryResult.Count; results.Data = queryResult.Data.Select(Map).ToList(); return(results); }
public ActionResult Index(bool? showInactive, string searchText, int itemsperpage = 10, int page = 1) { try { if (itemsperpage != null) { ViewModelBase.ItemsPerPage = itemsperpage; } bool showinactive = false; if (showInactive != null) showinactive = (bool)showInactive; ViewBag.showInactive = showinactive; ViewBag.searchParam = searchText; int currentPageIndex = page < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex * take; var query = new QueryStandard(); query.ShowInactive = showinactive; query.Skip = skip; query.Take = take; query.Name = searchText; var result = _serviceProvider.Query(query); var count = result.Count; var data = result.Data; return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, count)); } catch (DomainValidationException dve) { ValidationSummary.DisplayDomainValidationResult(dve, ModelState); return View(); } catch (Exception ex) { _log.Debug("Failed to list bank" + ex.Message); _log.Error("Failed to list bank" + ex.ToString()); return View(); } }
// GET: Counties public ActionResult Index(string searchString, bool showInactive = false, int itemsperpage = 10, int page = 1) { DisplayConfigurationMessage(); ViewModelBase.ItemsPerPage = itemsperpage; ViewBag.showInactive = showInactive; ViewBag.SearchString = searchString; int currentPageIndex = page - 1 < 0 ? 0 : page - 1; int take = itemsperpage; int skip = take * currentPageIndex; var query = new QueryStandard() { IncludeDeactivated = showInactive, Skip = skip, Take = take, Description = searchString }; var cvmList = _countyViewModelBuilder.Query(query); var countyList = cvmList.Data; return(View(countyList.ToPagedList(page, itemsperpage))); }
public QueryResult<ServiceProvider> Query(QueryStandard q) { IQueryable<tblServiceProvider> sProviderQuery; if (q.ShowInactive) sProviderQuery = _ctx.tblServiceProvider.Where(l => l.IM_IsActive == false || l.IM_IsActive == true).AsQueryable(); else sProviderQuery = _ctx.tblServiceProvider.Where(p => p.IM_IsActive == true).AsQueryable(); if (!string.IsNullOrWhiteSpace(q.Name)) sProviderQuery = sProviderQuery.Where(k => k.SPName.ToLower().Contains(q.Name.ToLower())); var queryResult = new QueryResult<ServiceProvider>(); queryResult.Count = sProviderQuery.Count(); sProviderQuery = sProviderQuery.OrderBy(l => l.SPName).ThenBy(o => o.SPCode); if (q.Skip.HasValue && q.Take.HasValue) sProviderQuery = sProviderQuery.Skip(q.Skip.Value).Take(q.Take.Value); var result = sProviderQuery.ToList(); queryResult.Data = result.Select(Map).ToList(); q.ShowInactive = false; return queryResult; }