Take the community feedback survey now.
                AI OnAI Off
            
        Take the community feedback survey now.
First
Although you don't need GetCategories I have rewritten including the GetCategories extension if you need it for the future
public class ParallaxNavigationBlockController : BlockController<ParallaxNavigationBlock>
{
    private readonly CategoryRepository _categoryRepository;
    public ParallaxNavigationBlockController(CategoryRepository categoryRepository) // Injected in. The correct way
    {
        _categoryRepository = categoryRepository;
    }
    public override ActionResult Index(ParallaxNavigationBlock currentBlock)
    {
        var firstCategory = (currentBlock as ICategorizable).Category.FirstOrDefault();
        var model = new ParallaxNavigationViewModel
        {
            Category = firstCategory > 0 ? _categoryRepository.Get(firstCategory) : null
        };
        return PartialView(model);
    }
}
// ViewModel
public class ParallaxNavigationViewModel
{
    public Category Category { get; set; }
}
public static class Extensions // Needs to be in a static class
{
    // Extension method for categories
    public static IEnumerable<Category> GetCategories(this CategoryList categoryList)
    {
        CategoryRepository categoryRepository = ServiceLocator.Current.GetInstance<CategoryRepository>();
        return categoryList.Select(x => categoryRepository.Get(x));
    }
}
                        
    
    
    
We tagging our blocks in episerver using the built in category.
problem is getting the category name so I can use it in the blocks view.
Tried the code below but it's saying GetCategory isn't available in the controller.