public async Task <IActionResult> ComponentTypesIndex() { var viewModel = new ComponentTypesIndexViewModel() { ComponentTypes = await _context.ComponentType.ToListAsync(), Categories = await _context.Category.ToListAsync(), SelectedCategoryId = _context.Category.FirstOrDefaultAsync(x => x.Name == "All").Result.CategoryId }; return(View(viewModel)); }
public async Task <IActionResult> ComponentTypesIndexForCategory(int selectedCategoryId) { var viewModel = new ComponentTypesIndexViewModel { ComponentTypes = await _context.ComponentType.ToListAsync(), Categories = await _context.Category.ToListAsync(), SelectedCategoryId = _context.Category.FirstOrDefaultAsync(x => x.CategoryId == selectedCategoryId) .Result.CategoryId, }; return(View("ComponentTypesIndex", viewModel)); }