public void Init(IEnumerable<Politician> politicians, PoliticianSearchSpec searchSpec) { Politicians = politicians.Select(politician => new SearchPoliticianModelDetail { Name = politician.Name, Location = politician.Location, Url = politician.Url, Capacity = politician.Capacity, Email = politician.Email }).ToList(); Pager = new PagerModel(searchSpec); if (searchSpec.Filter.TextSearch.Items.Any()) SearchTerm = searchSpec.Filter.TextSearch.Items.Aggregate((current, next) => current + " " + next); ResultCount = searchSpec.TotalItems; }
public void Init(IEnumerable<Person> persons, PersonSearchSpec searchSpec) { Persons = persons.Select(person => new SearchPersonModelDetail { Name = person.Name, Location = person.Location, Url = person.Url, Job = person.Job, Email = person.Email }).ToList(); Pager = new PagerModel(searchSpec); if (searchSpec.Filter.TextSearch.Items.Any()) SearchTerm = searchSpec.Filter.TextSearch.Items.Aggregate((current, next) => current + " " + next); ResultCount = searchSpec.TotalItems; }
public void Init(IEnumerable<Club> clubs, ClubSearchSpec searchSpec) { Clubs = clubs.Select(org => new SearchClubModelDetail { Name = org.Name, Location = org.Location, Url = org.Url, AreaOfWork = org.AreaOfWork, Email = org.Email }).ToList(); Pager = new PagerModel(searchSpec); if (searchSpec.Filter.TextSearch.Items.Any()) SearchTerm = searchSpec.Filter.TextSearch.Items.Aggregate((current, next) => current + " " + next); ResultCount = searchSpec.TotalItems; }
public void Init(IEnumerable<Company> orgas, CompanySearchSpec searchSpec) { Organisations = orgas.Select(org => new SearchCompanyModelDetail { Name = org.Name, Location = org.Location, Url = org.Url, Industry = org.Industry, Size = org.Size, Balance2011 = org.WelfareBalanceFor2011, Balance2012 = org.WelfareBalanceFor2012, Id = org.Id }).ToList(); Pager = new PagerModel(searchSpec); if (searchSpec.Filter.TextSearch.Items.Any()) SearchTerm = searchSpec.Filter.TextSearch.Items.Aggregate((current, next) => current + " " + next); ResultCount = searchSpec.TotalItems; }
public static MvcHtmlString Pager(this HtmlHelper html, PagerModel pager) { if (pager == null) return new MvcHtmlString(""); var newViewContext = new ViewContext(html.ViewContext, html.ViewContext.View, new ViewDataDictionary(pager), html.ViewContext.TempData, html.ViewContext.Writer); ViewEngineResult result = ViewEngines.Engines.FindPartialView( html.ViewContext, "~/Views/Shared/_Pager.cshtml"); var stringBuilder = new StringBuilder(); var stringWriter = new StringWriter(stringBuilder); result.View.Render(newViewContext, stringWriter); stringWriter.Flush(); return new MvcHtmlString(stringBuilder.ToString()); }