public async Task <ActionResult> EditModuleSettings(Guid pageVersionId, string position, object model) { var pageVersion = await pageService.GetPageVersionAsync(pageVersionId); var md = pageVersion.GetModule(position); await pageService.UpdateAsync(pageVersion); return(await ModuleFinder.Find(md.Type)?.Save(pageVersionId, position, Request.Form)); }
public static void Register(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment env) { FrameworkCore.Register(services, configuration); ModelRegister.Register(services); BusinessRegister.Register(services); MessageServiceRegister.Register(services, configuration); LoggerRegister.Register(services); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <StaticResources>(); services.AddSingleton <SessionManager>(); services.AddSingleton <CookiesManager>(); services.AddSingleton <IWebEnvironment, WebHost>(); services.AddTransient <ILanguageLocalization, LanguageLocalization>(); services.AddTransient <ViewRender>(); services.AddSingleton <IAccountContext, AccountContext>(); services.AddDistributedMemoryCache(); services.AddSession(); services.AddMemoryCache(); services.AddResponseCompression(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var mvcBuilder = services.AddControllersWithViews(options => { options.Filters.Add(typeof(GlobalFilter)); // options.Filters.Add(typeof(ExceptionFilter)); }).AddRazorRuntimeCompilation(); mvcBuilder.AddSessionStateTempDataProvider(); ModuleFinder moduleFinder = new ModuleFinder(env); var modules = moduleFinder.Find(); if (modules.Any()) { foreach (var module in modules) { // Register controller from modules mvcBuilder.AddApplicationPart(module.Assembly); } //Register module view location services.Configure <RazorViewEngineOptions>(options => { options.ViewLocationExpanders.Add(new ModuleViewLocationExpander()); }); } FrameworkCore.ServiceProvider = services.BuildServiceProvider(); }
public ActionResult RenderModule(Guid pageVersionId, string position) { var pageVersion = pageService.GetPageVersion(pageVersionId); var moduledata = pageVersion.ModuleData.FirstOrDefault(md => md.Position == position); if (moduledata != null) { var isEditor = Request.IsAjaxRequest(); return(ModuleFinder.Find(moduledata.Type)?.Index(pageVersionId, position, isEditor)); } return(Content("")); }