-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e507181
commit ad8b81a
Showing
12 changed files
with
177 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...src/main/java/com/diesel/BankApp/businessLogic/controllers/AccountRegisterController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Account> result; | ||
List<User> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters