public void AssignRoleToUser(Guid userID, Guid roleID) { var connection = new SqlConnection(connectionString); try { connection.Open(); var factory = new SqlCommandFactory(connection) .AsStoredProcedure("[dbo].[SP_UsersRoles_AssignRoleToUser]") .WithParams() .AddGuid("@roleID", roleID) .AddGuid("@userID", userID) .ParamsEnd(); factory.ExecuteNonQuery(); } catch (Exception) { // todo log exception #if DEBUG throw; #endif } finally { if (connection != null) { connection.Close(); } } }
public void DeleteRole(Guid roleID) { if (roleID == null) { throw new ArgumentNullException("roleID"); } var connection = new SqlConnection(connectionString); try { connection.Open(); var factory = new SqlCommandFactory(connection) .AsStoredProcedure("[dbo].[SP_Roles_DeleteRole]") .WithParams() .AddGuid("@roleID", roleID) .ParamsEnd(); factory.ExecuteNonQuery(); } catch (Exception) { // todo log exception #if DEBUG throw; #endif } finally { if (connection != null) { connection.Close(); } } }
public void SetUserLock(Guid userID, bool userLockStatus) { var connection = new SqlConnection(connectionString); try { connection.Open(); var factory = new SqlCommandFactory(connection) .AsStoredProcedure("[dbo].[SP_Users_LockUser]") .WithParams() .AddGuid("@userID", userID) .AddBit("@lockUser", userLockStatus) .ParamsEnd(); factory.ExecuteNonQuery(); } catch (Exception) { // todo log exception #if DEBUG throw; #endif } finally { if (connection != null) { connection.Close(); } } }