public IViewComponentResult Invoke()
 {
     return(new ViewViewComponentResult()
     {
         ViewData = new ViewDataDictionary <IEnumerable <Country> >(ViewData,
                                                                    _countryRepository.Countries())
     });
 }
Beispiel #2
0
        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)
            }));
        }
Beispiel #3
0
 public string Invoke()
 {
     return($"{_countryRepository.Countries().Count()} counties with a " +
            $"population of {_countryRepository.Countries().Sum(x => x.Population)}");
 }