Example #1
0
        public static void update(Guid userAccountID, Guid id, string username, string firstName, string lastName,
                                  string address1, string address2, string phone1, string phone2, string email, DateTime?birthdate, string identification, int height, int weight, string notes, List <Guid?> userAccountRoles)
        {
            UserAccount objOld = new UserAccount(id);
            string      log    = "";

            log = Util.appendChange(log, objOld.Username, username, "Username: '******' to '{1}'");
            log = Util.appendChange(log, objOld.Firstname, firstName, "First Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Lastname, lastName, "Last Name: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Address1, address1, "Address 1: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Address2, address2, "Address 2: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Phone1, phone1, "Phone 1: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Phone2, phone2, "Phone 2: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Email, email, "Email: '{0}' to '{1}'");
            log = Util.appendChange(log, objOld.Birthdate, birthdate, "Birthdate: '{0:dd MMM yyyy}' to '{1:dd MMM yyyy}'");
            log = Util.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                if (!string.IsNullOrEmpty(log))
                {
                    SqlQueryResult result = DBConnection.query(
                        sqlConnection,
                        QueryTypes.ExecuteNonQuery,
                        "UserAccounts_update",
                        new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                        new SqlQueryParameter(COL_DB_Username, SqlDbType.NVarChar, username),
                        new SqlQueryParameter(COL_DB_Firstname, SqlDbType.NVarChar, firstName),
                        new SqlQueryParameter(COL_DB_Lastname, SqlDbType.NVarChar, Util.wrapNullable(lastName)),
                        new SqlQueryParameter(COL_DB_Address1, SqlDbType.NVarChar, Util.wrapNullable(address1)),
                        new SqlQueryParameter(COL_DB_Address2, SqlDbType.NVarChar, Util.wrapNullable(address2)),
                        new SqlQueryParameter(COL_DB_Phone1, SqlDbType.NVarChar, Util.wrapNullable(phone1)),
                        new SqlQueryParameter(COL_DB_Phone2, SqlDbType.NVarChar, Util.wrapNullable(phone2)),
                        new SqlQueryParameter(COL_DB_Email, SqlDbType.NVarChar, Util.wrapNullable(email)),
                        new SqlQueryParameter(COL_DB_Birthdate, SqlDbType.NVarChar, Util.wrapNullable(birthdate)),
                        new SqlQueryParameter(COL_DB_Identification, SqlDbType.NVarChar, Util.wrapNullable(identification)),
                        new SqlQueryParameter(COL_DB_Height, SqlDbType.Int, Util.wrapNullable(height)),
                        new SqlQueryParameter(COL_DB_Weight, SqlDbType.Int, Util.wrapNullable(weight)),
                        new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                        );

                    if (result.IsSuccessful)
                    {
                        LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, String.Format("Updated: {0}", log));
                    }
                }
                UserAccountRoleAssignment.update(sqlConnection, userAccountID, id, userAccountRoles);
            }
        }
Example #2
0
        public static Guid add(Guid userAccountID, string username, string password, string firstName, string lastName,
                               string address1, string address2, string phone1, string phone2, string email, DateTime?birthdate, string identification, int height, int weight, string notes, List <Guid?> userAccountRoles)
        {
            Guid id = Guid.NewGuid();

            using (SqlConnection sqlConnection = new SqlConnection(DBConnection.ConnectionString))
            {
                SqlQueryResult result = DBConnection.query(
                    sqlConnection,
                    QueryTypes.ExecuteNonQuery,
                    "UserAccounts_add",
                    new SqlQueryParameter(COL_DB_Id, SqlDbType.UniqueIdentifier, id),
                    new SqlQueryParameter(COL_DB_Username, SqlDbType.NVarChar, username),
                    new SqlQueryParameter(COL_DB_Firstname, SqlDbType.NVarChar, firstName),
                    new SqlQueryParameter(COL_INPUT_Password, SqlDbType.NVarChar, password),
                    new SqlQueryParameter(COL_DB_Lastname, SqlDbType.NVarChar, Util.wrapNullable(lastName)),
                    new SqlQueryParameter(COL_DB_Address1, SqlDbType.NVarChar, Util.wrapNullable(address1)),
                    new SqlQueryParameter(COL_DB_Address2, SqlDbType.NVarChar, Util.wrapNullable(address2)),
                    new SqlQueryParameter(COL_DB_Phone1, SqlDbType.NVarChar, Util.wrapNullable(phone1)),
                    new SqlQueryParameter(COL_DB_Phone2, SqlDbType.NVarChar, Util.wrapNullable(phone2)),
                    new SqlQueryParameter(COL_DB_Email, SqlDbType.NVarChar, Util.wrapNullable(email)),
                    new SqlQueryParameter(COL_DB_Birthdate, SqlDbType.NVarChar, Util.wrapNullable(birthdate)),
                    new SqlQueryParameter(COL_DB_Identification, SqlDbType.NVarChar, Util.wrapNullable(identification)),
                    new SqlQueryParameter(COL_DB_Height, SqlDbType.Int, Util.wrapNullable(height)),
                    new SqlQueryParameter(COL_DB_Weight, SqlDbType.Int, Util.wrapNullable(weight)),
                    new SqlQueryParameter(COL_DB_Notes, SqlDbType.NVarChar, Util.wrapNullable(notes))
                    );

                if (result.IsSuccessful)
                {
                    LOGGING.ActivityLog.add(sqlConnection, userAccountID, id, "Added");
                    UserAccountRoleAssignment.update(sqlConnection, userAccountID, id, userAccountRoles);
                }
            }
            return(id);
        }