public async Task <IActionResult> Index(string keyword, int?CategoryID, int?BrandID, int pageIndex = 1, int pageSize = 10) { var categoryList = await _productApiClient.GetAllCategory(); var request = new GetProductPagingRequest() { Keyword = keyword, BrandID = BrandID, CategoryID = CategoryID, PageIndex = pageIndex, PageSize = pageSize, }; var data = await _productApiClient.GetProductPagings(request); if (TempData["result"] != null) { ViewBag.SuccessMsg = TempData["result"]; } if (TempData["error"] != null) { ViewBag.ErrorMsg = TempData["error"]; } var Categories = await OrderCateToTree(categoryList); var Brands = await _productApiClient.GetAllBrand(); ViewBag.Brands = Brands.Select(x => new SelectListItem() { Text = x.brand_name, Value = x.id.ToString(), Selected = BrandID != null && x.id == BrandID }); ViewBag.Categories = Categories.Select(x => new SelectListItem() { Text = x.cate_name, Value = x.id.ToString(), Selected = CategoryID != null && x.id == CategoryID }); return(View(data)); }