public IViewComponentResult Invoke() { return(new ViewViewComponentResult() { ViewData = new ViewDataDictionary <IEnumerable <Country> >(ViewData, _countryRepository.Countries()) }); }
public IViewComponentResult Invoke(bool useParameter) { if (useParameter) { return(Content("Doing something with the value provided from the parent view")); } var id = RouteData.Values["id"] as string; if (!string.IsNullOrWhiteSpace(id)) { return(Content($"The entered id is {id}")); } return(View(new CountryViewModel { Countries = _countryRepository.Countries().Count(), Population = _countryRepository.Countries().Sum(x => x.Population) })); }
public string Invoke() { return($"{_countryRepository.Countries().Count()} counties with a " + $"population of {_countryRepository.Countries().Sum(x => x.Population)}"); }