public async Task <IActionResult> Index(int id) { try { if (_listRepository.GetListById(id) != null) { var itemListViewModel = new ItemListViewModel { ListId = _listRepository.GetId(id), ListName = _listRepository.GetListName(id), Items = (List <Item>) await _itemRepository.GetAllItemsInList(id) }; return(View(itemListViewModel)); } else { return(NotFound()); } } catch (Exception ex) { _logger.LogError($"Failed to return list: {ex}"); return(BadRequest($"Failed to return list")); } }