I have a check for registration in my RegistrationController:
public class RegistrationController : Controller
{
private readonly IAmARegistrationRepository _RegistrationRepository;
public RegistrationController(IAmARegistrationRepository registrationRepository)
{
_RegistrationRepository = registrationRepository;
}
public bool IsRegistered(string userName)
{
return _RegistrationRepository.IsRegistered(userName);
}
}
How can I check this from my HomeController? Is there a way to access the ControllerBuilder to pull in the currently open controller if there is one? or to at least be able to generate one using the customer controller factory I’ve loaded into the ControllerBuilder in my Global.asax.cs?
I think you’re overthinking this. You already have a method on your repository that you can use. Why create another controller just to invoke a method that simply defers to the repository method? Create an instance of the repository in your HomeController and use the
IsRegisteredmethod on it.