public ConfigViewModel(bool prepareData) { if (prepareData) { Modules = InvocationHub.GetModules(); Users = InvocationHub.GetUsers(); } }
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 string GetUserPermissions(string ModuleName, int userID) { var res = new Dictionary <string, bool>(); var conn = new SqlConnection(InvocationHub.GetConnectionString()); IEnumerable <dynamic> data = conn.Query("SELECT p.PermissionName,CAST(uwd.Value AS BIT) Value FROM dbo.UserWidePermissionData uwd INNER JOIN dbo.UserWidePermissions p ON p.ID = uwd.PermissionID WHERE uwd.UserID = @userID AND p.ModuleName = @ModuleName" , new { userID, ModuleName }); foreach (var item in data) { res[item.PermissionName] = item.Value; } return(JsonConvert.SerializeObject(res)); }
private bool CreatePermission(UserWidePermissions permissions) { var conn = new SqlConnection(InvocationHub.GetConnectionString()); var count = conn.ExecuteScalar <int>("SELECT COUNT(1) FROM [UserWidePermissions] WHERE ModuleName = @ModuleName AND PermissionName=@PermissionName", permissions); if (count > 0) { return(false); } var cnt = conn.Execute("insert into [UserWidePermissions](ModuleName,PermissionName,PermissionTitle) values (@ModuleName,@PermissionName,@PermissionTitle)" , permissions); return(cnt > 0); }
private bool SetUserPermission(PermissionSavingData permissionSavingData) { var conn = new SqlConnection(InvocationHub.GetConnectionString()); try { var permissionID = conn.ExecuteScalar <int>("SELECT ID FROM dbo.UserWidePermissions WHERE ModuleName = @ModuleName AND PermissionName = @PermissionName", permissionSavingData); var cnt = conn.Execute("INSERT dbo.UserWidePermissionData(PermissionID,UserID,Value)VALUES(@permissionID,@UserID,@Value)" , new { permissionID, permissionSavingData.UserID, permissionSavingData.Value }); return(cnt > 0); } catch { return(false); } }
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)); } }