diff --git a/mobile-app/bank-app/app/build/intermediates/bundle_manifest/debug/processDebugManifest/bundle-manifest/AndroidManifest.xml b/mobile-app/bank-app/app/build/intermediates/bundle_manifest/debug/processDebugManifest/bundle-manifest/AndroidManifest.xml
index 2910ee6..24e5dbe 100644
--- a/mobile-app/bank-app/app/build/intermediates/bundle_manifest/debug/processDebugManifest/bundle-manifest/AndroidManifest.xml
+++ b/mobile-app/bank-app/app/build/intermediates/bundle_manifest/debug/processDebugManifest/bundle-manifest/AndroidManifest.xml
@@ -32,6 +32,18 @@
android:name="com.diesel.BankApp.presentation.activities.RegisterActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/AccountRegisterController.java b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/AccountRegisterController.java
new file mode 100644
index 0000000..bdf4e75
--- /dev/null
+++ b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/AccountRegisterController.java
@@ -0,0 +1,49 @@
+package com.diesel.BankApp.businessLogic.controllers;
+
+import android.content.Context;
+
+import com.diesel.BankApp.dataAccess.models.Account;
+import com.diesel.BankApp.dataAccess.models.User;
+import com.diesel.BankApp.dataAccess.repositories.AccountRepository;
+import com.diesel.BankApp.dataAccess.repositories.UserRepository;
+
+import java.sql.SQLException;
+import java.util.List;
+
+public class AccountRegisterController {
+ List result;
+ List resultUser;
+ AccountRepository accRepo = new AccountRepository();
+ UserRepository userRepo = new UserRepository();
+
+
+ public boolean register(int numero, String linkedUsername, double balance, Context context) {
+ //verifica que exista la cuenta de usuario
+ try {
+ resultUser = userRepo.getUserByName(linkedUsername, context);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return false;
+ }
+ User usuario;
+ if (!(resultUser.isEmpty())) {
+ usuario = resultUser.get(0);
+ } else {
+ return false;
+ }
+ int idUsuario = usuario.getId();
+ //verifica que no exista ya la cuenta de ahorros
+ try {
+ result = accRepo.getAccountByNumber(numero, context);
+ //TODO la cuenta ya existe
+ if (!(result.isEmpty())) {
+ return false;
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ //crea la nueva cuenta
+ accRepo.createAccount(new Account(numero, idUsuario, balance, " "), context);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/LoginController.java b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/LoginController.java
index f2bfcdb..1b34d63 100644
--- a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/LoginController.java
+++ b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/LoginController.java
@@ -25,8 +25,8 @@ public int login(String username, String password, Context context){
return 0;
}
currentUser = result.get(0);
- //verifica que la contraseña sea coerrecta.
- if(currentUser.getPassword()!=password){
+ //verifica que la contraseña sea correcta.
+ if (!currentUser.getPassword().equals(password)) {
//TODO error contraseña incorrecta
return 0;
}else{
diff --git a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/MainController.java b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/MainController.java
index eed9856..3e7b72b 100644
--- a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/MainController.java
+++ b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/MainController.java
@@ -8,5 +8,5 @@ public class MainController {
public static User usuario;
public static Account cuenta;
public static Administrator adminstrador;
-
}
+
diff --git a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/RegisterController.java b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/RegisterController.java
index 6b8c310..ebfff81 100644
--- a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/RegisterController.java
+++ b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/RegisterController.java
@@ -2,11 +2,11 @@
import android.content.Context;
import android.util.Base64;
-import android.util.Log;
import com.diesel.BankApp.dataAccess.models.User;
import com.diesel.BankApp.dataAccess.repositories.UserRepository;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.sql.SQLException;
import java.util.Calendar;
@@ -24,9 +24,10 @@ public class RegisterController {
public boolean register(int ID, String username, String password, Context context){
try {
result = userRepo.getUserById(ID,context);
- Log.d("demo account", result.toString());
//TODO la cuennta ya existe
- return false;
+ if (!(result.isEmpty())) {
+ return false;
+ }
}catch (SQLException e){
e.printStackTrace();
}
@@ -44,7 +45,7 @@ private String encriptar(String datos, String password) throws Exception{
}
private SecretKeySpec generateKey(String password) throws Exception{
MessageDigest sha = MessageDigest.getInstance("SHA-256");
- byte[] key = password.getBytes("UTF-8");
+ byte[] key = password.getBytes(StandardCharsets.UTF_8);
key = sha.digest(key);
SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
return secretKey;
diff --git a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/TransactionController.java b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/TransactionController.java
index e52fd23..8abf8e1 100644
--- a/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/TransactionController.java
+++ b/mobile-app/bank-app/app/src/main/java/com/diesel/BankApp/businessLogic/controllers/TransactionController.java
@@ -1,14 +1,14 @@
package com.diesel.BankApp.businessLogic.controllers;
import android.content.Context;
-import android.util.Log;
-import com.diesel.BankApp.dataAccess.database.Database;
import com.diesel.BankApp.dataAccess.models.Account;
import com.diesel.BankApp.dataAccess.repositories.AccountRepository;
-
import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
public class TransactionController {
@@ -18,46 +18,60 @@ public class TransactionController {
Account cuentaReceptor;
double newBalance;
- public boolean sendMoney(int idEmisor, double cantidad, int idReceptor, Context context){
+ public boolean sendMoney(int numeroEmisor, double cantidad, int numeroReceptor, Context context) {
//Busca la cuenta en la base de datos
try {
- result = accRepo.getAccountByIdLinked(idEmisor,context);
- Log.d("demo account", result.toString());
+ result = accRepo.getAccountByNumber(numeroEmisor, context);
} catch (SQLException e){
e.printStackTrace();
return false;
}
- //Compara el balance de la cuenta del emisor con la cantidad que se queire enviar
- cuentaEmisor = result.get(0);
+ //Compara el balance de la cuenta del emisor con la cantidad que se quiere enviar
+ if (!(result.isEmpty())) {
+ cuentaEmisor = result.get(0);
+ } else {
+ return false;
+ }
+
if(cuentaEmisor.getBalance()();
String[] splitter = MainController.cuenta.getHistory().split(";");
for (int i = 0; i < splitter.length; i++){
- history.add(splitter[1]);
+ history.add(splitter[i]);
}
initViews();
initLogOutTextView();