public static Boolean DeleteRole(RoleViewModel_Role view, string ConnectionString) { if (view.RoleID == null) { view.Errors.Add("Invalid Role ID"); } return(view.Errors.Count > 0 ? false : PermissionDataAccess.DeleteRole(view, ConnectionString)); }
public static Boolean AddPermissionToRole(RoleViewModel_Role role, RoleViewModel_Permission permission, string ConnectionString) { if (role.RoleID == null) { role.Errors.Add("Invalid Role ID"); } if (permission.PermissionID == null) { permission.Errors.Add("Invalid Permission ID"); } return(role.Errors.Count > 0 || permission.Errors.Count > 0 ? false : PermissionDataAccess.AddPermissionToRole(role, permission, ConnectionString)); }
public static Boolean DeleteRole(AccountViewModel account, RoleViewModel_Role role, string ConnectionString) { if (account.AccountID == null) { account.Errors.Add("Invalid Account ID"); } if (role.RoleID == null) { role.Errors.Add("Invalid Role ID"); } return(role.Errors.Count > 0 || account.Errors.Count > 0 ? false : AccountDataAccess.DeleteRole(account, role, ConnectionString)); }
public static Boolean DeleteRole(RoleViewModel_Role view, string ConnectionString) { try { DataAccess dataAccess = new DataAccess(ConnectionString, "spRoles_DeleteRole"); dataAccess.SetParamater_Input("@RoleID", view.RoleID, SqlDbType.Int); dataAccess.ExecuteNonQuery(); return(true); } catch (Exception ex) { view.Errors.Add(ex.Message); return(false); } }
public static Boolean AddPermissionToRole(RoleViewModel_Role role, RoleViewModel_Permission permission, string ConnectionString) { try { DataAccess dataAccess = new DataAccess(ConnectionString, "spRoles_AddPermissionToRole"); dataAccess.SetParamater_Input("@RoleID", role.RoleID, SqlDbType.Int); dataAccess.SetParamater_Input("@PermissionID", permission.PermissionID, SqlDbType.Int); dataAccess.ExecuteNonQuery(); return(true); } catch (Exception ex) { role.Errors.Add(ex.Message); return(false); } }
public static Boolean DeleteRole(AccountViewModel account, RoleViewModel_Role role, string ConnectionString) { try { DataAccess dataAccess = new DataAccess(ConnectionString, "spAccounts_DeleteAssignedRole"); dataAccess.SetParamater_Input("@AccountID", account.AccountID, SqlDbType.Int); dataAccess.SetParamater_Input("@RoleID", role.RoleID, SqlDbType.Int); dataAccess.ExecuteNonQuery(); return(true); } catch (Exception ex) { account.Errors.Add(ex.Message); return(false); } }
//Roles public static Boolean CreateRole(RoleViewModel_Role view, string ConnectionString) { try { DataAccess dataAccess = new DataAccess(ConnectionString, "spRoles_CreateRole"); dataAccess.SetParamater_Input("@RoleName", view.RoleName, SqlDbType.VarChar, 100); dataAccess.SetParamater_Output("@RoleID", SqlDbType.Int); dataAccess.ExecuteNonQuery(); view.RoleID = (int?)dataAccess.GetParamater("@RoleID"); return(true); } catch (Exception ex) { view.Errors.Add(ex.Message); return(false); } }
public static Boolean GetPermissionsByRole(RoleViewModel_Role view, string ConnectionString) { List <RoleViewModel_Permission> permissions = new List <RoleViewModel_Permission>(); try { DataAccess dataAccess = new DataAccess(ConnectionString, "spRoles_GetPermissionsByRole"); dataAccess.SetParamater_Input("@RoleID", view.RoleID, SqlDbType.Int); DataTable dt = dataAccess.ExcuteQuery(); foreach (DataRow row in dt.Rows) { view.Permissions.Add(new RoleViewModel_Permission() { PermissionID = (int?)row["PermissionID"], PermissionName = (string)row["PermissionName"], Controller = (string)row["Controller"], Action = (string)row["Action"], Priority = (int?)row["PermissionPriority"], PermissionGroup = new RoleViewModel_PermissionGroup() { PermissionGroupID = (int?)row["PermissionGroupID"], PermissionGroupName = (string)row["PermissionGroupName"], Priority = (int?)row["PermissionGroupPriority"], } }); } return(true); } catch (Exception ex) { view.Errors.Add(ex.Message); return(false); } }