/// <summary> /// Handle load index page /// </summary> /// <returns></returns> public async Task <IActionResult> OnGetAsync() { var catIdStr = Request.Query["id"]; var id = ParseTodoCatId(catIdStr); this.TodoCats = await _todoCatServices.GetTodoCategoryListAsync(); // The the first item on the list if (id == 0 && this.TodoCats.Count > 0) { this.ID = this.TodoCats[1].ID; } else if (id > 0) { var curCat = _todoCatServices.FindById(id); if (curCat == null) { return(RedirectToPage("./Error")); } this.ID = curCat.ID; } else if (this.TodoCats.Count == 0) { return(RedirectToPage("./Error")); } return(Page()); }
public async Task <IViewComponentResult> InvokeAsync(int selectedCatId) { var todoCatList = await _todoCatServices.GetTodoCategoryListAsync(); var todoCatViewModel = new TodoCatViewModel { SelectedCatId = selectedCatId, TodoCatList = todoCatList }; return(View(todoCatViewModel)); }