public async Task <IActionResult> ComponentIndexForType(int selectedComponentTypeId) { var viewModel = new ComponentIndexViewModel() { ComponentTypes = await _context.ComponentType.ToListAsync(), Components = await _context.Component.Where(x => x.ComponentTypeIdsList.Contains(selectedComponentTypeId)).ToListAsync(), SelectedComponentTypeId = _context.ComponentType.FirstOrDefaultAsync(x => x.ComponentTypeId == selectedComponentTypeId).Result.ComponentTypeId }; return(View("ComponentsIndex", viewModel)); }
public async Task <IActionResult> ComponentsIndex() { var viewModel = new ComponentIndexViewModel() { Components = await _context.Component.ToListAsync(), ComponentTypes = await _context.ComponentType.ToListAsync(), SelectedComponentTypeId = _context.ComponentType.FirstOrDefaultAsync(x => x.ComponentName == "All").Result.ComponentTypeId }; return(View(viewModel)); }