/// <summary> /// Update/Insert if id == 0 it is an insert /// </summary> /// <param name="externalIdentityIdentity"></param> /// <param name="externalSystem"></param> /// <param name="userID"></param> /// <param name="password"></param> /// <param name="attachedToPerson"></param> /// <param name="typeOfAccount"></param> /// <returns></returns> public BasicExternalIdentity SetExternalIdentity( int externalIdentityIdentity, ExternalIdentityType typeOfAccount, string externalSystem, string userID, string password, int attachedToPerson) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetExternalIdentity", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "pExternalIdentityIdentity", externalIdentityIdentity); AddParameterWithName(command, "pTypeOfAccount", typeOfAccount.ToString()); AddParameterWithName(command, "pExternalSystem", externalSystem.ToString()); AddParameterWithName(command, "pUserID", userID.ToString()); AddParameterWithName(command, "pPassword", password); AddParameterWithName(command, "pAttachedToPerson", attachedToPerson); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return(ReadExternalIdentityFromDataReader(reader)); } } } return(null); }
public BasicExternalIdentity GetExternalIdentityFromPersonIdAndType(int persId, ExternalIdentityType type) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand( "SELECT " + readFieldsSQL + " WHERE AttachedToPerson= @persId and ExternalIdentityTypeName = @typeName", connection); AddParameterWithName(command, "persId", persId); AddParameterWithName(command, "typeName", type.ToString()); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return(ReadExternalIdentityFromDataReader(reader)); } throw new ArgumentException("Unknown Identity"); } } }
public BasicExternalIdentity GetExternalIdentityFromUserIdAndType (string userid, ExternalIdentityType type) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand( "SELECT " + readFieldsSQL + " WHERE UserID = @userid and ExternalIdentityTypeName = @type", connection); AddParameterWithName(command, "userid", userid); AddParameterWithName(command, "type", type.ToString()); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return ReadExternalIdentityFromDataReader(reader); } throw new ArgumentException("Unknown Identity"); } } }
/// <summary> /// Update/Insert if id == 0 it is an insert /// </summary> /// <param name="externalIdentityIdentity"></param> /// <param name="externalSystem"></param> /// <param name="userID"></param> /// <param name="password"></param> /// <param name="attachedToPerson"></param> /// <param name="typeOfAccount"></param> /// <returns></returns> public BasicExternalIdentity SetExternalIdentity ( int externalIdentityIdentity, ExternalIdentityType typeOfAccount, string externalSystem, string userID, string password, int attachedToPerson) { using (DbConnection connection = GetMySqlDbConnection()) { connection.Open(); DbCommand command = GetDbCommand("SetExternalIdentity", connection); command.CommandType = CommandType.StoredProcedure; AddParameterWithName(command, "pExternalIdentityIdentity", externalIdentityIdentity); AddParameterWithName(command, "pTypeOfAccount", typeOfAccount.ToString()); AddParameterWithName(command, "pExternalSystem", externalSystem.ToString()); AddParameterWithName(command, "pUserID", userID.ToString()); AddParameterWithName(command, "pPassword", password); AddParameterWithName(command, "pAttachedToPerson", attachedToPerson); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { return ReadExternalIdentityFromDataReader(reader); } } } return null; }