private bool Insert(int userID, string createdAt, string updatedAt) { bool isSuccess = false; int rowsAffacted = 0; StringBuilder sqliteQueryInsert = new StringBuilder(); sqliteQueryInsert.Append("INSERT INTO orders"); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("user_id, "); sqliteQueryInsert.Append("created_at, "); sqliteQueryInsert.Append("updated_at "); sqliteQueryInsert.Append(") "); sqliteQueryInsert.Append("VALUES "); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("@user_id, "); sqliteQueryInsert.Append("@created_at, "); sqliteQueryInsert.Append("@updated_at "); sqliteQueryInsert.Append(")"); SQLiteDataAdapter sqliteDataAdapterInsert = new SQLiteDataAdapter(); sqliteDataAdapterInsert.InsertCommand = new SQLiteCommand(); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@user_id", userID); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@created_at", createdAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@updated_at", updatedAt); dataAccessObject = new DataAccessLayer(); rowsAffacted = dataAccessObject.Insert(sqliteQueryInsert.ToString(), sqliteDataAdapterInsert); if (rowsAffacted > 0) { isSuccess = true; } return(isSuccess); }
private bool Insert() { bool isSuccess = false; int rowsAffacted = 0; var email = TextBoxEmail.Text.Trim(); var password = TextBoxPassword.Text.Trim(); var passwordConfirmation = TextBoxConfirmPassword.Text.Trim(); var encryptedPassword = Secure.Encrypt(password); var signInCount = 1; var dateTimeNow = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.FFFFF"); var currentSignInAt = dateTimeNow; var lastSignInAt = dateTimeNow; var signInIPAddress = ""; var currentSignInIP = signInIPAddress; var lastSignInIP = signInIPAddress; var createdAt = dateTimeNow; var updatedAt = dateTimeNow; CreditCard credCard = CreateCreditCard(); var creditCardID = credCard.id; var creditCardDescription = credCard.number; StringBuilder sqliteQueryInsert = new StringBuilder(); sqliteQueryInsert.Append("INSERT INTO users"); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("email, "); sqliteQueryInsert.Append("encrypted_password, "); sqliteQueryInsert.Append("sign_in_count, "); sqliteQueryInsert.Append("current_sign_in_at,"); sqliteQueryInsert.Append("last_sign_in_at, "); sqliteQueryInsert.Append("current_sign_in_ip, "); sqliteQueryInsert.Append("last_sign_in_ip, "); sqliteQueryInsert.Append("created_at, "); sqliteQueryInsert.Append("updated_at, "); sqliteQueryInsert.Append("credit_card_id, "); sqliteQueryInsert.Append("credit_card_description "); sqliteQueryInsert.Append(") "); sqliteQueryInsert.Append("VALUES "); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("@email, "); sqliteQueryInsert.Append("@encrypted_password, "); sqliteQueryInsert.Append("@sign_in_count, "); sqliteQueryInsert.Append("@current_sign_in_at,"); sqliteQueryInsert.Append("@last_sign_in_at, "); sqliteQueryInsert.Append("@current_sign_in_ip, "); sqliteQueryInsert.Append("@last_sign_in_ip, "); sqliteQueryInsert.Append("@created_at, "); sqliteQueryInsert.Append("@updated_at, "); sqliteQueryInsert.Append("@credit_card_id, "); sqliteQueryInsert.Append("@credit_card_description "); sqliteQueryInsert.Append(")"); SQLiteDataAdapter sqliteDataAdapterInsert = new SQLiteDataAdapter(); sqliteDataAdapterInsert.InsertCommand = new SQLiteCommand(); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@email", email); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@encrypted_password", encryptedPassword); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@sign_in_count", signInCount); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@current_sign_in_at", currentSignInAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@last_sign_in_at", lastSignInAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@current_sign_in_ip", currentSignInIP); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@last_sign_in_ip", lastSignInIP); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@created_at", createdAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@updated_at", updatedAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@credit_card_id", creditCardID); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@credit_card_description", creditCardDescription); dataAccessObject = new DataAccessLayer(); rowsAffacted = dataAccessObject.Insert(sqliteQueryInsert.ToString(), sqliteDataAdapterInsert); if (rowsAffacted > 0) { isSuccess = true; } return isSuccess; }
private bool Insert() { bool isSuccess = false; int rowsAffacted = 0; var email = TextBoxEmail.Text.Trim(); var password = TextBoxPassword.Text.Trim(); var passwordConfirmation = TextBoxConfirmPassword.Text.Trim(); var encryptedPassword = Secure.Encrypt(password); var signInCount = 1; var dateTimeNow = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.FFFFF"); var currentSignInAt = dateTimeNow; var lastSignInAt = dateTimeNow; var signInIPAddress = ConfigManager.Instance.GetProperty("IPAddress"); var currentSignInIP = signInIPAddress; var lastSignInIP = signInIPAddress; var createdAt = dateTimeNow; var updatedAt = dateTimeNow; CreditCard credCard = CreateCreditCard(); var creditCardID = credCard.id; var creditCardDescription = credCard.number; StringBuilder sqliteQueryInsert = new StringBuilder(); sqliteQueryInsert.Append("INSERT INTO users"); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("email, "); sqliteQueryInsert.Append("encrypted_password, "); sqliteQueryInsert.Append("sign_in_count, "); sqliteQueryInsert.Append("current_sign_in_at,"); sqliteQueryInsert.Append("last_sign_in_at, "); sqliteQueryInsert.Append("current_sign_in_ip, "); sqliteQueryInsert.Append("last_sign_in_ip, "); sqliteQueryInsert.Append("created_at, "); sqliteQueryInsert.Append("updated_at, "); sqliteQueryInsert.Append("credit_card_id, "); sqliteQueryInsert.Append("credit_card_description "); sqliteQueryInsert.Append(") "); sqliteQueryInsert.Append("VALUES "); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("@email, "); sqliteQueryInsert.Append("@encrypted_password, "); sqliteQueryInsert.Append("@sign_in_count, "); sqliteQueryInsert.Append("@current_sign_in_at,"); sqliteQueryInsert.Append("@last_sign_in_at, "); sqliteQueryInsert.Append("@current_sign_in_ip, "); sqliteQueryInsert.Append("@last_sign_in_ip, "); sqliteQueryInsert.Append("@created_at, "); sqliteQueryInsert.Append("@updated_at, "); sqliteQueryInsert.Append("@credit_card_id, "); sqliteQueryInsert.Append("@credit_card_description "); sqliteQueryInsert.Append(")"); SQLiteDataAdapter sqliteDataAdapterInsert = new SQLiteDataAdapter(); sqliteDataAdapterInsert.InsertCommand = new SQLiteCommand(); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@email", email); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@encrypted_password", encryptedPassword); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@sign_in_count", signInCount); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@current_sign_in_at", currentSignInAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@last_sign_in_at", lastSignInAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@current_sign_in_ip", currentSignInIP); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@last_sign_in_ip", lastSignInIP); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@created_at", createdAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@updated_at", updatedAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@credit_card_id", creditCardID); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@credit_card_description", creditCardDescription); dataAccessObject = new DataAccessLayer(); rowsAffacted = dataAccessObject.Insert(sqliteQueryInsert.ToString(), sqliteDataAdapterInsert); if (rowsAffacted > 0) { isSuccess = true; } return(isSuccess); }
private bool Insert(int userID, string createdAt, string updatedAt) { bool isSuccess = false; int rowsAffacted = 0; StringBuilder sqliteQueryInsert = new StringBuilder(); sqliteQueryInsert.Append("INSERT INTO orders"); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("user_id, "); sqliteQueryInsert.Append("created_at, "); sqliteQueryInsert.Append("updated_at "); sqliteQueryInsert.Append(") "); sqliteQueryInsert.Append("VALUES "); sqliteQueryInsert.Append("("); sqliteQueryInsert.Append("@user_id, "); sqliteQueryInsert.Append("@created_at, "); sqliteQueryInsert.Append("@updated_at "); sqliteQueryInsert.Append(")"); SQLiteDataAdapter sqliteDataAdapterInsert = new SQLiteDataAdapter(); sqliteDataAdapterInsert.InsertCommand = new SQLiteCommand(); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@user_id", userID); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@created_at", createdAt); sqliteDataAdapterInsert.InsertCommand.Parameters.AddWithValue("@updated_at", updatedAt); dataAccessObject = new DataAccessLayer(); rowsAffacted = dataAccessObject.Insert(sqliteQueryInsert.ToString(), sqliteDataAdapterInsert); if (rowsAffacted > 0) { isSuccess = true; } return isSuccess; }