public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { var builder = new ContainerBuilder(); //Register all controllers in Tree name space builder.RegisterApiControllers(typeof(CustomTreeController).Assembly); //register umbraco MVC + WebApi controllers used by the admin site builder.RegisterControllers(typeof(UmbracoApplication).Assembly); builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly); builder.Register(context => { var options = new DbContextOptionsBuilder <CustomSectionDbContext>(); options.UseInMemoryDatabase(databaseName: "CustomSection"); var ctx = new CustomSectionDbContext(options.Options); return(ctx); }).InstancePerRequest(); var container = builder.Build(); //Set the MVC DependencyResolver DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); //Set the WebApi DependencyResolver GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container); //Seed the database CustomSectionDbInitializer.Initialize(DependencyResolver.Current.GetService <CustomSectionDbContext>()); }
public DashboardController(CustomSectionDbContext dbContext) { _dbContext = dbContext; }
public SortController(CustomSectionDbContext dbContext) { _dbContext = dbContext; }
public NodeController(CustomSectionDbContext dbContext) { _dbContext = dbContext; }
public CustomTreeController(CustomSectionDbContext dbContext) { _dbContext = dbContext; }
public CustomTreeController() { _dbContext = DependencyResolver.Current.GetService <CustomSectionDbContext>(); }