/// <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);
        }
Example #2
0
 public ExternalIdentity SetExternalIdentity(string ExternalSystem,
                                             string UserID,
                                             string Password,
                                             int AttachedToPerson,
                                             ExternalIdentityType TypeOfAccount)
 {
     return(FromBasic(SwarmDb.GetDatabaseForWriting().SetExternalIdentity(
                          Identity, TypeOfAccount, ExternalSystem,
                          UserID, Password, AttachedToPerson)));
 }
        private BasicExternalIdentity ReadExternalIdentityFromDataReader(DbDataReader reader)
        {
            int externalIdentityId             = (int)reader["ExternalIdentityIdentity"];
            ExternalIdentityType typeOfAccount = (ExternalIdentityType)Enum.Parse(typeof(ExternalIdentityType), reader["ExternalIdentityTypeName"].ToString());
            string externalSystem   = (string)reader["ExternalSystem"];
            string userID           = (string)reader["UserID"];
            string password         = (string)reader["Password"];
            int    attachedToPerson = (int)reader["AttachedToPerson"];

            return(new BasicExternalIdentity(externalIdentityId, typeOfAccount, externalSystem, userID, password, attachedToPerson));
        }
 public BasicExternalIdentity ( int ExternalIdentityIdentity,
                                 ExternalIdentityType TypeOfAccount,
                                 string ExternalSystem,
                                 string UserID,
                                 string Password,
                                 int AttachedToPersonID)
 {
     this.externalIdentityIdentity = ExternalIdentityIdentity;
     this.externalSystem = ExternalSystem;
     this.userID = UserID;
     this.password = Password;
     this.attachedToPersonID = AttachedToPersonID;
     this.typeOfAccount = TypeOfAccount;
 }
 public BasicExternalIdentity(int ExternalIdentityIdentity,
                              ExternalIdentityType TypeOfAccount,
                              string ExternalSystem,
                              string UserID,
                              string Password,
                              int AttachedToPersonID)
 {
     this.externalIdentityIdentity = ExternalIdentityIdentity;
     this.externalSystem           = ExternalSystem;
     this.userID             = UserID;
     this.password           = Password;
     this.attachedToPersonID = AttachedToPersonID;
     this.typeOfAccount      = TypeOfAccount;
 }
Example #6
0
 public static ExternalIdentity CreateExternalIdentity(string ExternalSystem,
                                                       string UserID,
                                                       string Password,
                                                       int AttachedToPerson,
                                                       ExternalIdentityType TypeOfAccount)
 {
     try
     {
         return(FromBasic(SwarmDb.GetDatabaseForWriting().SetExternalIdentity(
                              0, TypeOfAccount, ExternalSystem,
                              UserID, Password, AttachedToPerson)));
     }
     catch (Exception ex)
     {
         throw new Exception("Failed to create ExternalIdentity", ex);
     }
 }
        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");
                }
            }
        }
Example #8
0
 public static ExternalIdentity FromUserIdAndType(string userid, ExternalIdentityType type)
 {
     return(FromBasic(SwarmDb.GetDatabaseForReading().GetExternalIdentityFromUserIdAndType(userid, type)));
 }
Example #9
0
 public static ExternalIdentity FromPersonIdAndType(int persId, ExternalIdentityType type)
 {
     return(FromBasic(SwarmDb.GetDatabaseForReading().GetExternalIdentityFromPersonIdAndType(persId, type)));
 }
        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;
        }
Example #12
0
        public static ExternalIdentity CreateExternalIdentity (string ExternalSystem,
                                        string UserID,
                                        string Password,
                                        int AttachedToPerson,
                                        ExternalIdentityType TypeOfAccount)
        {
            try
            {
                return FromBasic(SwarmDb.GetDatabaseForWriting().SetExternalIdentity(
                    0, TypeOfAccount, ExternalSystem,
                    UserID, Password, AttachedToPerson));
            }
            catch(Exception ex)
            {
                throw new Exception("Failed to create ExternalIdentity", ex);
            }


        }
Example #13
0
        public ExternalIdentity SetExternalIdentity (string ExternalSystem,
                                        string UserID,
                                        string Password,
                                        int AttachedToPerson,
                                        ExternalIdentityType TypeOfAccount)
        {
            return FromBasic(SwarmDb.GetDatabaseForWriting().SetExternalIdentity(
                this.Identity, TypeOfAccount, ExternalSystem,
                UserID, Password, AttachedToPerson));



        }
Example #14
0
 public static ExternalIdentity FromPersonIdAndType (int persId, ExternalIdentityType type)
 {
     return FromBasic(SwarmDb.GetDatabaseForReading().GetExternalIdentityFromPersonIdAndType(persId, type));
 }
Example #15
0
 public static ExternalIdentity FromUserIdAndType (string userid, ExternalIdentityType type)
 {
     return FromBasic(SwarmDb.GetDatabaseForReading().GetExternalIdentityFromUserIdAndType(userid, type));
 }