From 749d20880f7309ac11b2d64ecb53375ce432c73e Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Sun, 27 Jun 2021 11:34:14 -0700 Subject: [PATCH] changed structure --- src/bank.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bank.cpp b/src/bank.cpp index 468496e..59f99ce 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -48,7 +48,7 @@ BankResponse Bank::GetLogs(const std::string &name) noexcept temp[i - 1]["amount"] = (Json::UInt)u.log.data[u.log.data.size() - i].amount; temp[i - 1]["time"] = (Json::UInt64)u.log.data[u.log.data.size() - i].time; } - res = {HttpStatusCode::k200OK, std::move(temp)}; + res = {k200OK, std::move(temp)}; }); return res; } @@ -78,19 +78,19 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam Transaction temp(a_name, b_name, amount); std::shared_lock lock{send_funds_l}; users.modify_if(a_name, [this, &temp, &state, amount](User &a) { - //if A can afford it and A's password matches attempt + //if A can afford it if (a.balance < amount) { - state = {k200OK, "Sender has insufficient funds"}; + state = {k204NoContent, "Sender has insufficient funds"}; } else { a.balance -= amount; a.log.AddTrans(Transaction(temp)); - state = {HttpStatusCode::k200OK, "Transfer successful!"}; + state = {k200OK, "Transfer successful!"}; } }); - if (state.first == HttpStatusCode::k200OK) + if (state.first == k200OK) { users.modify_if(b_name, [&a_name, &b_name, &temp, amount](User &b) { b.balance += amount; @@ -107,7 +107,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam //if A can afford it and A's password matches attempt if (a.balance < amount) { - state = {k200OK, "Sender has insufficient funds"}; + state = {k204NoContent, "Sender has insufficient funds"}; } else {