public async Task OnPost() { if (string.IsNullOrWhiteSpace(SearchModel.KeyString)) { SearchModel = new SearchChildViewModel(); SearchModel.Children = new List <Child>(); RedirectToPage(); } var list = await _childServices.GetAllChildrenAsync(); if (list.Count > 0) { list = list .Where(c => c.Fullname.ToLower() .Contains(SearchModel.KeyString.ToLower())) .ToList(); SearchModel = new SearchChildViewModel(); SearchModel.Children = new List <Child>(); SearchModel.Children = list; RedirectToPage(); } else { SearchModel = new SearchChildViewModel(); SearchModel.Children = new List <Child>(); RedirectToPage(); } }
public async Task <IActionResult> OnGet() { ViewData["Title"] = "All Children"; ViewModel = new AllChildrenViewModel(); ViewModel.Children = new List <Child>(); var response = await _child.GetAllChildrenAsync(); if (response.Count > 0) { ViewModel.Children = response; } return(Page()); }