示例#1
0
        public async Task <IViewComponentResult> InvokeAsync(VcDemoType vcDemoType)
        {
            var fruits = _repo.GetFruits();

            switch (vcDemoType)
            {
            case VcDemoType.RazorPages:
                return(await Task.FromResult <IViewComponentResult>(View("RazorPages", fruits)));

            case VcDemoType.RazorPagesPrg:
                return(await Task.FromResult <IViewComponentResult>(View("RazorPagesPrg", fruits)));

            case VcDemoType.Api:
                return(await Task.FromResult <IViewComponentResult>(View("Api", fruits)));

            case VcDemoType.ApiAjax:
                return(await Task.FromResult <IViewComponentResult>(View("ApiAjax", fruits)));

            default:
                return(await Task.FromResult <IViewComponentResult>(View(fruits)));
            }
        }
 public IActionResult Get()
 {
     return(Ok(_repo.GetFruits()));
 }
 public IActionResult OnGet()
 {
     return(new JsonResult(_repo.GetFruits()));
 }