public static string GetThemeLayoutPath(this IHtmlHelper helper) { var context = helper.ViewContext.HttpContext; if (InvocationHub.IsModuleInDebugMode() || !context.Items.ContainsKey(Consts.CONTEXT_ITEM_KEY_THEME_LAYOUT_PATH)) { return("_Layout"); } return(context.Items[Consts.CONTEXT_ITEM_KEY_THEME_LAYOUT_PATH].ToString()); }
public static async Task <IHtmlContent> Component(this IViewComponentHelper viewComponentHelper, string moduleName, string viewComponentName) { if (InvocationHub.IsModuleInDebugMode()) { return(await viewComponentHelper.InvokeAsync(viewComponentName)); } else { return(await viewComponentHelper.InvokeAsync("Renderer", new { moduleName, viewComponentName })); } }
public static string GetAdminLayout(this IHtmlHelper helper) { var context = helper.ViewContext.HttpContext; if (InvocationHub.IsModuleInDebugMode() || !context.Items.ContainsKey(Consts.CONTEXT_ITEM_KEY_ADMIN_THEME_LAYOUT_PATH)) { return("_Layout"); } helper.ViewData["User"] = InvocationHub.GetCurrentUser(); return(context.Items[Consts.CONTEXT_ITEM_KEY_ADMIN_THEME_LAYOUT_PATH].ToString()); }
public static ViewResult GetView(this Microsoft.AspNetCore.Mvc.Controller ctrl, [CallerMemberName] string name = "", object model = null) { name = GetLastMethodName(name); if (InvocationHub.IsModuleInDebugMode()) { return(ctrl.View(name, model)); } else { var mdlName = ctrl.ControllerContext.HttpContext.Items[Consts.CONTEXT_ITEM_KEY_THEME_MODULE_NAME].ToString(); var controllerName = ctrl.GetType().Name.Replace("Controller", "", StringComparison.OrdinalIgnoreCase); var path = $"{Consts.MODULES_BASE_PATH}\\{mdlName}\\Views\\{controllerName}\\"; var file = ""; try { file = Directory.GetFiles(path, $"{name}.*").Single(); } catch (FileNotFoundException) { throw new ViewFileNotFoundException(mdlName, controllerName, name); } return(ctrl.View($"~/{path.Replace("\\","/")}{new FileInfo(file).Name}", model)); } }