package de.fau.amos.virtualledger.server.savings;

import de.fau.amos.virtualledger.server.model.SavingsAccount;

import javax.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.List;

@ApplicationScoped
public class SavingsController {


    List<SavingsAccount> savingsAccountList = new ArrayList<>();

    public List<SavingsAccount> getSavingAccounts(String email) {

        return savingsAccountList;
    }

    public void addSavingAccount(String email, SavingsAccount savingsAccount) throws SavingsException {

        savingsAccount.id = savingsAccountList.size();
        savingsAccountList.add(savingsAccount);
    }
}


@@ -105,16 +105,94 @@
 Account;
+%0Aimport de.fau.amos.virtualledger.server.persistence.SavingsAccountRepository;
 %0A%0Aimport
@@ -251,22 +251,22 @@
 java
-.util.ArrayLis
+x.inject.Injec
 t;%0Ai
@@ -345,18 +345,113 @@
  %7B%0A%0A
-%0A    List%3C
+    private SavingsAccountRepository savingsAccountRepository;%0A%0A    @Inject%0A    public SavingsController(
 Savi
@@ -460,17 +460,26 @@
 sAccount
-%3E
+Repository
  savings
@@ -489,33 +489,133 @@
 ount
-List = new ArrayList%3C%3E();
+Repository) %7B%0A        this.savingsAccountRepository = savingsAccountRepository;%0A    %7D%0A    protected  SavingsController () %7B %7D
 %0A%0A  
@@ -708,20 +708,63 @@
 sAccount
-List
+Repository.getSavingsAccountsByUserEmail(email)
 ;%0A    %7D%0A
@@ -895,50 +895,26 @@
 ount
-.id = savingsAccountList.size();%0A        s
+Repository.createS
 avin
@@ -926,17 +926,16 @@
 ount
-List.add(
+(email, 
 savi

use the SavingsAccountRepository instead of storing in RAM in SavingsController