//public IViewComponentResult Invoke()
        //{
        //    var viewModel = new NavBarViewModel();
        //    viewModel.Years = yearsService.GetLastYears(5);
        //    return View(viewModel);
        //}

        public IViewComponentResult Invoke(int count)
        {
            var viewModel = new NavBarViewModel
            {
                Years = yearsService.GetLastYears(count)
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
 public IActionResult FromServiceAttribute([FromServices] IYearsService years)
 {
     return(Json(years.GetLastYears(5)));
 }
Exemplo n.º 3
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     context.HttpContext.Response.Headers.Add("X-Years", string.Join(",", yearsService.GetLastYears(5)));
 }