I'm trying out Autofac and the architecture described in this article. With Ninject I used to be able to use the following to retireve the current user using Ninject:
kernel.Bind<ApplicationUser>().ToMethod(c => (System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>()).FindById(System.Web.HttpContext.Current.User.Identity.GetUserId<int>()));
Using the above, one could then easily get access to the currently logged in user in both your controllers and repositories e.g:
private readonly ApplicationUser _user;
public ProductsController(ApplicationUser user)
{
_user = user;
}
private readonly ApplicationUser _user;
public SectorRepository(ApplicationUser user)
{
_user = user;
}
I've experimented with Autofac and so far could not achieve the same results
How would I be able to accomplish the same or similar using Autofac?