public DataObject.RolePermission GetUserRole(int Id) { DataObject.RolePermission role = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "[Security].[GetRolePermissions] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { role = new DataObject.RolePermission(); while (reader.Read()) { role.Id = int.Parse(reader.GetValue(0).ToString()); role.CanManageSchedule = Convert.ToBoolean(reader.GetValue(1).ToString()); role.CanManageZones = Convert.ToBoolean(reader.GetValue(2).ToString()); role.CanManageSwitches = Convert.ToBoolean(reader.GetValue(3).ToString()); role.CanManageUnits = Convert.ToBoolean(reader.GetValue(4).ToString()); role.CanSwitchOnOff = Convert.ToBoolean(reader.GetValue(5).ToString()); role.CanManageUsers = Convert.ToBoolean(reader.GetValue(6).ToString()); } } } } return role; }
public DataObject.RolePermission GetUserRole(int Id) { DataObject.RolePermission role = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "[Security].[GetRolePermissions] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { role = new DataObject.RolePermission(); while (reader.Read()) { role.Id = int.Parse(reader.GetValue(0).ToString()); role.CanManageSchedule = Convert.ToBoolean(reader.GetValue(1).ToString()); role.CanManageZones = Convert.ToBoolean(reader.GetValue(2).ToString()); role.CanManageSwitches = Convert.ToBoolean(reader.GetValue(3).ToString()); role.CanManageUnits = Convert.ToBoolean(reader.GetValue(4).ToString()); role.CanSwitchOnOff = Convert.ToBoolean(reader.GetValue(5).ToString()); role.CanManageUsers = Convert.ToBoolean(reader.GetValue(6).ToString()); } } } } return(role); }