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