MCPcopy Create free account
hub / github.com/actix/examples / create_customer

Function create_customer

databases/mysql/src/persistence.rs:122–148  ·  view source on GitHub ↗
(
    pool: &mysql::Pool,
    customer_name: String,
    branch_name: String,
)

Source from the content-addressed store, hash-verified

120}
121
122pub fn create_customer(
123 pool: &mysql::Pool,
124 customer_name: String,
125 branch_name: String,
126) -> Result<(), PersistenceError> {
127 if customer_name.replace(' ', "").trim().is_empty() {
128 return Err(PersistenceError::EmptyCustomerName);
129 }
130
131 if branch_name.replace(' ', "").trim().is_empty() {
132 return Err(PersistenceError::EmptyBranch);
133 }
134
135 let mut conn = pool.get_conn()?;
136
137 let last_insert_id = insert_customer_data(
138 &mut conn,
139 customer_name.to_lowercase(),
140 branch_name.to_lowercase(),
141 )?;
142
143 if last_insert_id > 0 {
144 Ok(())
145 } else {
146 Err(PersistenceError::Unknown)
147 }
148}
149
150pub fn get_bank_data(pool: &mysql::Pool) -> Result<BankResponseData, PersistenceError> {
151 let mut conn = pool.get_conn()?;

Callers 1

add_customerFunction · 0.85

Calls 1

insert_customer_dataFunction · 0.85

Tested by

no test coverage detected